[Qt-interest] QtScript, custom QObject subclasses, and hasOwnProperties()
Kent Hansen
khansen at trolltech.com
Tue Feb 17 13:10:41 CET 2009
Hi Nathan,
Nathan Carter wrote:
> Since my previous post didn't go over so well (i.e., no responses :) )
> I'll rephrase:
>
> When I incorporate QObjects into script land in the method recommended
> by Qt's documentation, I get objects with the C++-land methods and
> properties exposed directly in the object, not factored out to a
> common prototype object. Is this the intended behavior or am I doing
> something wrong?
>
Yes, that's the way it works currently.
> If it is the intended behavior, then how do I achieve my desired
> behavior of putting all methods in the prototype object? Do I have to
> create a custom C++ class for the prototype object that just forwards
> all method calls to inside the thisObject? That seems like
> reinventing the wheel, and that there must be a better way.
>
> Nathan
>
There's currently no way of avoiding slots being properties of each
object when using newQObject(), I'm afraid.
If there were a QScriptEngine::ExcludeMethods wrap option, you could
have a prototype object that doesn't use that option, whereas instances
that do use it; this should give you the desired behavior. But there is
no such option (yet).
Kent
More information about the Qt-interest-old
mailing list