[Qt-interest] Treating User defined type as QVariant via void*
Stephen Kelly
steveire at gmail.com
Wed Sep 22 15:17:19 CEST 2010
Santhosh Y wrote:
>
> // Trying to insert Node* as UserType inside QVariant
> QVariant v (QVariant::UserType, a);
>
> Node* k =NULL;
>
> // bool status = qVariantCanConvert<Node*>(v);
>
>
> if ( v.canConvert<Node*>() )
> k = v.value<Node*>();
>
>
> if (k != NULL) {
>
> std::cout << "Able to read back from void* to Node*\n";
> }
after you do Q_DECLARE_METATYPE(NODE*) you want something like:
QVariant v = QVariant::fromValue(a);
Node* k =NULL;
k = v.value<Node*>();
More information about the Qt-interest-old
mailing list