[Qt-interest] Meta Object for Class Name?
Josiah Bryan
jbryan at productiveconcepts.com
Wed Nov 11 19:46:52 CET 2009
Sean Harmer wrote:
> Josiah Bryan wrote:
>> Is there a way to get the meta object for a class given the class name
>> (assuming its a QObject, of course.)
>>
>> Ideally, I'd like to be able to construct a class just from its name, say:
>>
>> FooBar *foo = (FooBar*) QMetaObject::defaultConstructor("FooBar");
>>
>> Is that pie-in-the-sky or is that somehow possible?
>>
> I think you are after QObject* QMetaObject::newInstance():
>
> http://doc.trolltech.com/4.6-snapshot/qmetaobject.html#newInstance
>
Awesome! Thanks, Sean. Maybe I'm blind, but I didn't see anything in the
docs where I can get the QMetaObject for a class name, e.g. something like:
static QMetaObject * QMetaObject::metaObject(const char * className);
Any ideas if thats possible or not?
Thanks!
-josiah
More information about the Qt-interest-old
mailing list