Creating class objects through its name stored in a string?

Is it possible to create a class object at run time by retrieving the name of the class stored in a string?

for example: I want to create an object of class QButton , for example

 QString strClassName = "QButton"; QButton *pBtn = new strClassName(); 

I want to read the xml file of all the controls and instantiate them at runtime using this method.

+6
c ++ qt qt4
source share
2 answers

Are you looking for functionality provided by QUiLoader ?

+8
source share

In general, you can look at them. As another poster noted, this functionality exists in Qt for (at least) Qt classes.

General factory in C ++

Is there a way to create objects from a string containing their class name?

+2
source share

All Articles