[Qt-interest] Returning a QObjectList from a slot in a QScriptable/QObject derived object?
Frank Hemer
frank at hemer.org
Thu Oct 15 22:01:29 CEST 2009
On Thursday 15 October 2009 21:50:12 Bastian Bense wrote:
> Hello all,
>
> I'm experimenting a bit with QtScript and I was wondering why the following
> is not working:
>
> The Qt documentation states that there is a default conversion of types
> from C++ to QtScript and vice versa.
>
> >From what I read this seems to be true for slots declared in objects that
>
> derive from QObject and QScriptable. While the slots work fine as long they
> return some standard values like int, QString and so on, this does not seem
> to be true for slots that return a QObjectList.
>
> In the documentation it says that there is a default conversion to a
> QtScript array with all objects in the array being converted by
> newQObject().
>
> Here is some example code:
>
>
> class CpsJob :
> public QObject,
> public QScriptable
> {
> Q_OBJECT
>
> public:
> CpsJob();
>
> public slots:
> QObjectList testObjects();
>
> };
>
>
> As you can see there is a public slot called testObjects(). If I call this
> slot from the script, I get an exception that tells me to register the type
> using qScriptRegisterMetaType() first. Am I doing something obviously
> wrong?
Are you using the 4.6 preview/beta?
Take a look at qt4-preview-feedback, I just posted a bugreport and demo
code ...
Frank
More information about the Qt-interest-old
mailing list