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
New Developer
Posts: 75
Registered: ‎08-15-2013
My Device: blackberry curve 9630
My Carrier: Airtel

Difference between toList and value() for QVariant in blackberry cascades

Hi All,

 

While working on QVariant i noticed that in orde to access element of QVariant there are two ways:

 

eg:-

 

 

QVariant  tempQVariant;

tempQVariant.value<QVariantList> 

 

 

This will return the QVariantList which is stored inside QVariant. However there is another approach as:-

 

tempQVariant.toList()

 

Please tell whats the difference between them and  will there be difference in data returned from both of them.

 

Objective is to access QVariantMap stored inside QVariantList which is stored inside QVariant.

 

Thanks & Regards 

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Difference between toList and value() for QVariant in blackberry cascades

If the QVariant type is a list then it will return a list in this respect it's no different from using toInt, toLong, etc.

There is little difference using either value or one of the toXXX functions and if you look at the documentation it says the same thing...

 

http://qt-project.org/doc/qt-4.8/qvariant.html#value

 

Depending on your code however using the toXXX functions you may be able to do away with using a validity check beforehand as you should do with value.

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.