Initialize TextField placeholderText with value received from a signal
Solved
QML and Qt Quick
-
Hello all !
I have a C++ Q_OBJECT for which I have defined a Q_PROPERTY so that I can expose my patientID variable to QML:
Q_PROPERTY(QString patientID READ patientID NOTIFY changedPatientID)
I have exposed this object to my QML like this:
ConfigWatch* configwatch = new ConfigWatch(); engine.rootContext()->setContextProperty("configwatch", configwatch);
In my QML I have a TextField
TextField { id: myTextField placeholderText: qsTr("I want to initialize this field with my configwatch.patientID value") }
Binding my configwatch to QML and using configwatch.patientID works well, but I am wondering if there is a way to update placeholderText with whatever value is in configwatch.patientID. Note that patientID will only be updated once at launch.
Thanks for any help !