[Qt-interest] classname to metaobject

Mohammed Sameer msameer at foolab.org
Mon Jul 27 14:36:16 CEST 2009


On Mon, Jul 27, 2009 at 02:21:21PM +0200, Imre Péntek wrote:
> Hello,
> 
> Is there any way to get a metaobject corresponding to a given string (as a 
> classname)?
> 
> e.g. is there any_function which would work like this:
> any_function("QObject")==QObject::staticMetaObject;
> 
> or similarily
> QObject *x=...;
> any_function(x->metaObject().className())==x->metaObject();
> 
> and similarily:
> QString x="QPushButton"; //or any other classname
> any_function(x).className()==x;

Hi,

Why don't you do it the other way around ?

QObject::staticMetaObject->className() == QString("QObject")


-- 
GPG-Key: 0xA3FD0DF7 - 9F73 032E EAC9 F7AD 951F  280E CB66 8E29 A3FD 0DF7
Debian User and Developer.
Homepage: www.foolab.org



More information about the Qt-interest-old mailing list