[Qt-interest] Dynamically instantiate a class using the class name
Mandeep Sandhu
mandeepsandhu.chd at gmail.com
Mon Jul 5 15:19:00 CEST 2010
Hi All,
Is there a way to programmatically instantiate a class given it's name?
Eg: I'm making a library which calls upon other helper classes to do
the actual job. So a user calls a method say - setHelper(QString
helpername) in this lib, and the lib internally instantiates an object
of a class who's name is specified in "helpername". I'll have the
"helper" classes follow a set interface so that my lib routines have a
uniform way of interacting with all such helpers.
Does the QT meta system provide such a feature?
In java, Class.forName(String className) provides this functionality.
Is there something similar in QT too?
Regards,
-mandeep
More information about the Qt-interest-old
mailing list