I am experiencing with the new QQuickWidget. How can I interact between the QQuickWidget and C++?
C++
QQuickWidget *view = new QQuickWidget();
view->setSource(QUrl::fromLocalFile("myqml.qml"));
view->setProperty("test", 0);
myLayout->addWidget(view);
QML
import QtQuick 2.1
Rectangle {
id: mainWindow
width: parent.width
height: parent.height
Text {
id: text
width: mainWindow.width
font.pixelSize: 20
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: test
}
}
text: test
does not work: ReferenceError: test is not defined
How can I give my QML file some properties via C++?
Is it also possible to get the Text object in C++ and update its text?
setContextProperty("test", 0)
doesn't work as well assetContextProperty("test", "some random text")
– Finbur