0

How to send a variable from c++ to qml? Can you send me an exampe.

Aziz
  • 1
  • 1
    Did you try searching at all? Why didn't the results help? What kind of variable are you trying to send, and when? This is very unclear and lacking in evidence of research/effort. – underscore_d Jun 18 '20 at 11:54
  • 1
    Does this answer your question? [Passing parameters from C++ to QML](https://stackoverflow.com/questions/45716708/passing-parameters-from-c-to-qml) or [Expose variable from c++ to qml](https://stackoverflow.com/questions/51286723/expose-variable-from-c-to-qml) or etc., etc. – underscore_d Jun 18 '20 at 11:55

1 Answers1

0

I think you are looking for something like this

look at backend.userName

TextField {
    text: backend.userName
    placeholderText: qsTr("User name")
    anchors.centerIn: parent

    onTextChanged: backend.userName = text
}
crsn
  • 609
  • 4
  • 11