[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: [PyQt] Invoke function QML with arguments
From: Charlie Gentil <ceg () redaction-developpez ! com>
Date: 2014-02-21 17:56:48
Message-ID: 2515438.EdfUtL0TB6 () charlie
[Download RAW message or body]
Le vendredi 21 février 2014, 17:25:27 Phil Thompson a écrit :
> On 19-02-2014 6:18 pm, Charlie Gentil wrote:
> > Hello,
> >
> > I want to invoke a function from QML Python. I use this:
> >
> > obj=app.rootObjects()
> >
> > myObject=obj[0].findChild(QObject,'myObj')
> >
> > QMetaObject.invokeMethod(myObject,"myTest",Qt.DirectConnection)
> >
> > It works fine, but now I have to pass arguments.
> >
> > I tried this:
> >
> > obj=app.rootObjects()
> >
> > myObject=obj[0].findChild(QObject,'myObject')
> >
> > QMetaObject.invokeMethod(myObject,"myTest",Qt.DirectConnection,
> > Q_ARG(int, 1020
>
> You need to use Q_ARG(QVariant, 1020)
>
> > My QML function :
> >
> > functionmyTest(x){
> >
> > console.log(x)
> >
> > }
> >
> > But I have this error in return:
> >
> > QMetaObject::invokeMethod: No such method
> > MyQML_QMLTYPE_100::myTest(int)
> >
> > QMetaObject.invokeMethod(myObject, "myTest", Qt.DirectConnection,
> > Q_ARG(int, 1020))
> >
> > RuntimeError: QMetaObject.invokeMethod() call failed
> >
> > Can you help me?
> >
> > In advance thank you
> >
> > Charlie
>
> A more readable solution would be to do...
>
> myObject.myTest(1020)
>
> Phil
> _______________________________________________
> PyQt mailing list PyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Hi,
It was really too simple ... I did not think at all.
thank you very much
Charlie
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic