Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Regular Contributor
Posts: 62
Registered: ‎03-07-2011
My Device: Z10 + PlayBook
My Carrier: Telus

foreach Syntax

Here's a quick one. I've got this code for a Prayer Journal application. It is copied straight out of the Bucket List sample other than changing the variables from Bucket to Prayer. It is giving a warning for Syntax Error, although it isn't showing up on the Problems list. Is it correct? And if not, what needs to change?

 

    foreach (QVariant v, mPrayerData){
		if(v.toMap().value("status") == filter) {
		  filteredPrayerData << v;
		  append(v.toMap());
		}
    }

 

Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: foreach Syntax

[ Edited ]

Looks ok to me. Does it compile?

Try replacing foreach with Q_FOREACH, maybe IDE will like it more. Smiley Happy

 


Andrey Fidrya, @zmeyc on twitter
Regular Contributor
Posts: 62
Registered: ‎03-07-2011
My Device: Z10 + PlayBook
My Carrier: Telus

Re: foreach Syntax

It does compile, pushes to device and then it is stuck on the splashscreen, so I don't think this is actually the problem, but since I can't find many more likely suspects I'm investigating every IDE error just in case. Using Q_FOREACH didn't change anything.

Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: foreach Syntax

Can you please show how mPrayerData is declared and created?

Andrey Fidrya, @zmeyc on twitter
Regular Contributor
Posts: 62
Registered: ‎03-07-2011
My Device: Z10 + PlayBook
My Carrier: Telus

Re: foreach Syntax

From prayermodel.h

  QVariantList mPrayerData;