Hello! Recently it was necessary to understand Qt GUI , and I encountered one problem with QLineEdit . In general, I have an object of type QLineEdit , and I use it in the QWizardPage . The program shows the starting address that can be edited. How, after editing, to refer to the text that is written in the object QLineEdit . Knowledge in Qt not enough, do not judge strictly.

 QLabel oldWay = new QLabel("Way to Existed File:"); QLineEdit oldWayEdit = new QLineEdit; QLabel newWay = new QLabel("Way to Created File:"); QLineEdit newWayEdit = new QLineEdit; 

Further in these fields the data changes, and I need to take the changed data. I do not know how. I looked at Qt Project all the features, but to no avail

  • one
    Use oldWayEdit->text() . - Costantino Rupert
  • I used it, but it will only store the initial data, and which function to use, so that after I make changes, you can save the new data. - Beraliv pm
  • Is it possible to do so? I have the original empty oldWayEdit-> text (), then I check it with ..-> isModified () and after that I use oldWayEdit-> textChanged (I just don’t understand what to enter here) - Beraliv

1 answer 1

oldWayEdit-> text () will store the initial data first, and after editing the text new data. What data you will get depends on when you read them :) Usually, new data is read from the input fields when the following events occur:

  • closing a form with input fields
  • switching to a new page (multipage forms)
  • the end of input in a specific field

Let's consider the last option. To implement it, you need to write your handler (slot) in which you will read data from QLineEdit. You connect this slot (the connect function) to the QLineEdit editingFinished () or returnPressed () signal ( or both). When the user finishes entering text, QLineEdit will emit the editingFinished () signal, and your slot attached to this signal will read the new text. That's all.

  • Thank you very much! They wrote just what I wanted to understand. Thanks for clarifying! - Beraliv