Answer the question
In order to leave comments, you need to log in
How to handle events in Qt?
Hey! I recently switched to Qt creator, and began to study it in detail. And then immediately asked the question "And how to handle events?". I didn't really find anything in Google and decided to ask here...
Tell me, how can I handle events in Qt? Like pressing a button?
And one more question. How to access other components on the form? For example, "if( TextField.text == 'Hi') Text.text = 'Hi!'
Answer the question
In order to leave comments, you need to log in
You, of course, use the form editor built into Qt Creator ...
1. Visually: RMB, Go to slot ...
Programmatically: the connect function, this was described by AtomKrieg .
2. All components are in add. object ui
. When you make a form programmatically, they don't have to be there, but the form editor does just that.
if (ui->textEdit->text() == "Hi") label->setText("Hi!");
Read Schlee's book or the official signal slot reference doc.qt.io/qt-4.8/signalsandslots.html
Hook the slot to the doc.qt.io/qt-5/qlineedit.html#textChanged signal and already write your pod in it by the input parameter. const QString &text
If the class is QTextEdit, in the handler, look at the text from doc.qt.io/qt-4.8/qtextedit .html#plainText-prop
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question