Hello,
we have an application that heavily integrates C++ and QML. Now, the need arises to call a javascript method defined on a QML component with a parameter that is a QQuickItem *. Here is the relevant QML code:
Rectangle {
function show(targetItem) {
_internal_stackView.push({item:targetItem,destroyOnPop:false})
}
}
Rectangle {
function show(targetItem) {
_internal_stackView.push({item:targetItem,destroyOnPop:false})
}
}
To copy to clipboard, switch view to plain text mode
from C++, I would like to do this:
QMetaObject::invokeMethod(m_qmlItem,
"show", Q_RETURN_ARG
(QVariant, retval
), Q_ARG
(QQuickItem
*, nextItemToShow
));
QMetaObject::invokeMethod(m_qmlItem, "show", Q_RETURN_ARG(QVariant, retval), Q_ARG(QQuickItem *, nextItemToShow));
To copy to clipboard, switch view to plain text mode
but alas, there seems to be no way to pass anything but primitve values (those supported by QVariant) as method parameter. The code compiles, but upon execution there is a message in the console that the parameter is inacceptable. I have also not found any other way to pass the "nextItemToShow" (context property doesn't work because context not writeable, QML property has the same restrictions as QML method)
Any suggestions?
thanks,
Chris
Bookmarks