[Qt-interest] Meta Object for Class Name?

Sean Harmer sean.harmer at maps-technology.com
Wed Nov 11 19:44:23 CET 2009


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

Have fun,

Sean

> Thanks!
> -josiah
>
>   




More information about the Qt-interest-old mailing list