[Qt-interest] Calling a QML-method within C++-code
Hendrik vP
variadic.template at googlemail.com
Mon Apr 4 11:59:12 CEST 2011
Hi,
I defined a method with one argument within QML that i want
to invoke in C++. In C++, I have the object that got the function
added as slot, I also can see that the slot is added by iterating
the methods within the metaobject. And, invoking a QML-method
that has no arguments, already worked fine.
The type of the argument is a QObject * and I expect to be able
to access its properties within QML simply by
function foo(item) {
console.log("start")
console.log(item.my_property)
console.log("end")
}
As the type of the arguments are QVariants within C++, i tried to
call it by
metamethod.invoke(target, Q_ARG(QVariant(QMetaType::QObjectStar,
my_qobject)))
I'm receiving no errors on the terminal, but also I'm only receiving
the "start"-method, it seems to break when i try to access the property.
Trying to print the item itself by console.log(item) gives me a "undefined".
So, is it even possible to use a QObject* as QML-method-argument and
when yes, how?
- Hendrik
References:
http://doc.qt.nokia.com/4.7.1/qml-extending-types.html#adding-new-methods
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110404/1cc3ea1f/attachment.html
More information about the Qt-interest-old
mailing list