[Qt-interest] QMetaType question

JD Guzman lostinthecode at googlemail.com
Sun Jan 17 16:49:18 CET 2010


Good afternoon,

I was trying to work with QMetaType to create a instance of a class that
I have made.  I followed the documentation and have gotten to the point
that I am doing the following:

    int id = QMetaType::type("MyClass");

    if (id != 0)
    {
        qDebug("MyClass found ...");
        void* controller = QMetaType::construct(id);
    }

I do get the "MyClass found ..." message and there are no errors so I am
assuming that everything is good up to there.  My question is where do I
go from here?  Since controller is type void* I cannot call any of the
functions in MyClass.  I tried casting but that didn't work either.
 >From the documentation it makes it seem that after constructing the
class with QMetaType::construct(id) I should be able to use my class.
But how?

Any enlightment would be appreciated.

Cheers



More information about the Qt-interest-old mailing list