Qt 3.1b1

Adam Treat manyoso at yahoo.com
Tue Sep 10 17:16:59 BST 2002


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 = QMetaObject::createClassInstance( "MyClass" );
> > >
> > > is soooo attractive for script bindings... :)
> >
> > We thought about that too, but finding the constructors is harder than 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 manual
> > 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 with 
all the overloaded ctors.  Such as:

QObject *obj = QMetaObject::createClassInstance( "MyClass(Type, Int, Blah)", 
mytype, myint, myblah );

This would be _very_ helpful to scripting engines and the like.

Cheers,

Adam






More information about the kde-core-devel mailing list