Hello, all;
Is there a simple way to swap text on a QPushButton when it's toggled? I currently have it labeled as a "play" button and want it to display "pause" when clicked. Thanks in advance.
Hello, all;
Is there a simple way to swap text on a QPushButton when it's toggled? I currently have it labeled as a "play" button and want it to display "pause" when clicked. Thanks in advance.
Hi,
use the toggled signal and connect it to following slot:Of course you can alter the code...Qt Code:
button->setText(button->isChecked() ? "pause" : "play");To copy to clipboard, switch view to plain text mode
Lykurg
Thank you, Lykurg! Is this the correct syntax?:
Qt Code:
taStartPB->setText(taStartPB->isChecked() ? "Pause" : "Play");To copy to clipboard, switch view to plain text mode
taStartPB is the name of my QPushButton. Using this code seems to allow the program to run and compile, but will not switch the text when the button is toggled...
Yes it is. Alternatively you can use the bool delivered by the signal instead of checking the isChecked(). So is your slot reached? have you set of the signal-slot connection properly? Did you use setCheckable(true) for your button?
bizmopeen (10th February 2010)
I think I see the issue in my signal-slot connection. Thank you again!
Bookmarks