sachi
sachi

Reputation: 479

How to get the text from the textfield in Qt creator?

I have a QML TextField in Qt creator. I want to get the text from the textfield UI. How do I do that?

Upvotes: 2

Views: 5257

Answers (1)

sam-w
sam-w

Reputation: 7687

You need to have 'named' your TextFields with ids. If an object has an id, you can use it as a handle to access properties from it. For example, imagine you want to clone the text from one textfield to another:

TextField {
  id: textField1
  text: "Text"
}

TextField {
  id: textField2
  text: textField1.text
}

You can find more detail here.

Upvotes: 6

Related Questions