[Interest] How to create QObject-derived class instance from class name
Thiago Macieira
thiago.macieira at intel.com
Wed Mar 2 18:51:21 CET 2016
On quarta-feira, 2 de março de 2016 13:04:35 PST Nye wrote:
> I just meant that in my case the classes are defined in the user
> application, so the library has no notion whatsoever what classes it has
> available to create instances from and it depends on the meta-type system
> exclusively for that (while still handling the
> serialization/deserialization of said instances). It just makes a factory
> inapplicable in my case (at least if you're not counting the meta-type
> system as a factory).
You don't know the list when you write the code, but you do know the list at
runtime. The full set of classes that can be instantiated needs to be
registered with a central authority.
You can either use QMetaType for that or your own registration/factory.
But it needs to be done.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
More information about the Interest
mailing list