Wednesday, 15 September 2010

c++ - How can I cast a QVariant to custom class? -



c++ - How can I cast a QVariant to custom class? -

i'm developing blackberry 10 mobile application using momentics ide (native sdk).

i have listview want handle items click c++ (i need utilize c++ not qml).

i can index path using "connect" instruction, have problem parsing qvariant custom class ;

q_assert(qobject::connect(list1, signal(triggered(qvariantlist)), this, slot(opensheet(qvariantlist)))); qvariant selectitem = m_categorieslistdatamodel->data(indexpath);

i tried utilize static cast below

category* custtype = static_cast<category*>(selectitem);

but returns :

"invalid static_cast type 'qvariant' type 'category*'"

can help me on ?

you seek using qvariant_cast , qobject_cast.

qobject *object = qvariant_cast<qobject*>(selectitem); category *category = qobject_cast<category*>(object);

also, never set persistent statement q_assert. not used when assert not enabled.

c++ qt blackberry-10 cascade qvariant

No comments:

Post a Comment