QPushbutton using method?
-
Hello to everyone,
I'm newbie to Qt and trying to learn. For example, I want to change the content of a QLabel with a QPushbutton. To do this, I write a private slot function and it gets what I want, but I doubted if this is the right (simplest) way. Is there an alternative way to do this job without writing slots?
Thanks for attention...
PS: I'm coding in C++....
-
@Endorfin35
No alternative, you absolutely should put a slot on the button click and set the label text there as you describe, this is the correct paradigm with Qt. -
@Endorfin35 said in QPushbutton using method?:
Is there an alternative way to do this job without writing slots?
No, if you want to do something when a button is clicked you have to use signals/slots. Also, signals/slots is one of the most basic things in Qt.
Actually there is one simplification you can do: instead of implementing a slot method use a C++ lambda function. -
@JonB said in QPushbutton using method?:
@Endorfin35
No alternative, you absolutely should put a slot on the button click and set the label text there as you describe, this is the correct paradigm with Qt.This is my answer. Thanks guys.