Hello,
I'm new in Qt-Quick and QML.
I'm learning how to use it with C++.
So I start with this tutorial and I use Q_PROPERTY(QString userName READ userName WRITE setUserName NOTIFY userNameChanged) :
https://doc.qt.io/qt-5/qtqml-cppintegration-topic.html
with the only difference that I use pageform.ui.qml files.
so on a pageforme I have a text field:
TextField {
id: textfield
text: "Text"
placeholderText: qsTr("User name")
anchors.centerIn: parent
}
TextField {
id: textfield
text: "Text"
placeholderText: qsTr("User name")
anchors.centerIn: parent
}
To copy to clipboard, switch view to plain text mode
and in main.qml:
Page3Form {
textfield
{
text: backend.userName
onTextChanged: backend.userName = text
}
}
Page3Form {
textfield
{
text: backend.userName
onTextChanged: backend.userName = text
}
}
To copy to clipboard, switch view to plain text mode
if I use it like that onTextChaned doesn't works and I've got an error in the debugger console:
qrc:/main.qml:51: ReferenceError: text is not defined
qrc:/main.qml:51: ReferenceError: text is not defined
To copy to clipboard, switch view to plain text mode
But if I do this in main.qml :
Page3Form {
textfield
{
text: backend.userName
onTextChanged: backend.userName = textfield.text
}
}
Page3Form {
textfield
{
text: backend.userName
onTextChanged: backend.userName = textfield.text
}
}
To copy to clipboard, switch view to plain text mode
It works but I have this message:
qrc:/Page3Form.ui.qml:25:5: QML TextField: Binding loop detected for property "text"
qrc:/Page3Form.ui.qml:25:5: QML TextField: Binding loop detected for property "text"
To copy to clipboard, switch view to plain text mode
is someone has a clue?
Regards.
Bookmarks