I have define many class,and their names are like this:
Icon1,Icon2,Icon3,....,Icon1000;
Now I want to know that how to create an object of them dynamicly by the digital in their names?
For example,If I know 6,how I create the object of Icon6?
I have define many class,and their names are like this:
Icon1,Icon2,Icon3,....,Icon1000;
Now I want to know that how to create an object of them dynamicly by the digital in their names?
For example,If I know 6,how I create the object of Icon6?
Last edited by weixj2003ld; 10th August 2011 at 02:37. Reason: soryy
First thing if you are creating 1000 classes of Icon (like Icon1, Icon2....) then you should be doing something which is way out of the way. Rather you should be creating hierarchy of classes and objects of them.
Second, the only option to create the object (IMO), with just knowing the digit in the class name is to create a switch statement with 1000 cases. I am sure no-body would like to write such thing, unless code automatically generated.
If those classes inherited QObject, they could be marshalled by name.
Bookmarks