Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Initialize TextField placeholderText with value received from a signal
Forum Updated to NodeBB v4.3 + New Features

Initialize TextField placeholderText with value received from a signal

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 215 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    elcou
    wrote on last edited by
    #1

    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 !

    1 Reply Last reply
    0
    • E Offline
      E Offline
      elcou
      wrote on last edited by
      #2

      Apparently just a

      placeholderText: configwatch.patientID
      

      Works fine !

      Sorry about that, I thought that I had already tried this...

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved