[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: Qt 3.1b1
From:       Adam Treat <manyoso () yahoo ! com>
Date:       2002-09-10 16:16:59
[Download RAW message or body]

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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic