Hello,
ok I make it clearer.
Rectangle{
id::root
property string mystring:"Hello"
Button{
id: btnTest
width:140
height: 30
text: "btnTest"
onClicked: {
console.log(root.mystring)
}
MyPlugin{
id:plugin1
Component.onCompleted: {
}
}
}
Rectangle{
id::root
property string mystring:"Hello"
Button{
id: btnTest
width:140
height: 30
text: "btnTest"
onClicked: {
console.log(root.mystring)
}
MyPlugin{
id:plugin1
Component.onCompleted: {
}
}
}
To copy to clipboard, switch view to plain text mode
When I load my qml file through qml.exe it loads the qml file and my property string mystring is equal to "Hello".
Then in MyPlugin::componentComplete I make this:
QQmlEngine *mrtEngine = qmlEngine(this);
QQmlComponent component(mrtEngine, "path/to/file.qml");
QObject *object
= component.
create();
qCritical() << "Property value:" << QQmlProperty::read(object, "mystring").toString();
QQmlProperty::write(object, "mystring", "Hello QtCentre");
delete object;
QQmlEngine *mrtEngine = qmlEngine(this);
QQmlComponent component(mrtEngine, "path/to/file.qml");
QObject *object = component.create();
qCritical() << "Property value:" << QQmlProperty::read(object, "mystring").toString();
QQmlProperty::write(object, "mystring", "Hello QtCentre");
delete object;
To copy to clipboard, switch view to plain text mode
So now when I click my Button mystring is equal to "Hello" and not "Hello QtCentre"?!?
Bookmarks