I'm doing the following as a quick workaround for now.
But I'm pretty much sure that the broken QObjectList return value for slots
in QtScript is a bug that has something to do with the migration to the new
script engine.


QScriptValue CpsJob::testObjects()
{
*[...]*

    QObjectList resultList;

*[...]*

    return qScriptValueFromSequence(engine(), resultList);
}


2009/10/16 Bastian Bense <[email protected]>

> I accidently reported this to the qt-interested mailing list yesterday.
>
> For those who want to reproduce it, I made a small test project that
> clearly shows the problem:
> http://dl.getdropbox.com/u/2374297/qt4scriptbug.tar.gz
>
> 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();
>
> };
>
> Here the idea is to use testObjects() from the script to get a list of
> QObject*s which I can can then use in the script.
>
> If I call this slot from the script, I get an exception that tells me to
> register the type using qScriptRegisterMetaType() first. I assume this is a
> bug.
>
> ...or I'm doing something obviously wrong?
>
>


-- 
Best regards,
Bastian
_______________________________________________
Qt4-preview-feedback mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt4-preview-feedback

Reply via email to