From kde-core-devel Tue Sep 10 16:16:59 2002 From: Adam Treat Date: Tue, 10 Sep 2002 16:16:59 +0000 To: kde-core-devel Subject: Re: Qt 3.1b1 X-MARC-Message: https://marc.info/?l=kde-core-devel&m=103167457213529 On Monday 09 September 2002 05:25 am, Simon Hausmann wrote: > > > But the qt_static_property stuff is very cool, or rather the fact > > > that meta objects are registered through static objects at load > > > time. How about adding a little factory functionality in the > > > generated moc code to instantiate the actual class? :-) > > > > > > I could imagine that the problem though is to 'provide' all > > > constructors the class offers, and how to call them... > > > > > > But the thought of > > > > > > QObject *obj =3D QMetaObject::createClassInstance( "MyClass" ); > > > > > > is soooo attractive for script bindings... :) > > > > We thought about that too, but finding the constructors is harder tha= n it > > seems. Either moc has to parse the whole public section of a class > > declaration to look for a standard-QObject constructor (which is out = of > > moc's scope) or we have to introduce a macro which indicates a > > standard-QObject constructor. In the latter case this is a lot of man= ual > > work and so it is not much harder to write a factory class for all > > constructable objects (like we do with QWidgetFactory). > > Ah, right, /me remembers Q_BUILDER in Torben's emoc hacks ;-) > > Bummer. > > Simon Even cooler would be to allow the dynamic/runtime creation of QObjects wi= th=20 all the overloaded ctors. Such as: QObject *obj =3D QMetaObject::createClassInstance( "MyClass(Type, Int, Bl= ah)",=20 mytype, myint, myblah ); This would be _very_ helpful to scripting engines and the like. Cheers, Adam