Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[Solved] How to Toggle qpushbutton name
hello guys i want to toggle qpushbutton name means when i hit the push button once, push button should have name as "add" and when i hit it again it should have sub and when i hit it gain it should show again add.
How can i do it
plz help me guys
Use a slot connected to the clicked() signal, or if you are using a checkable button the toggled(bool) signal.
In the slot, verify the current text and change it accordingly or if your button is checkable, update the name based on whether the button is checked or not.
[edit: corrected wrong wording]
@addButton = new QPushButton(tr("add"));
connect(addButton, SIGNAL(clicked()),this, SLOT(slotButtonaddPressed()));
I have done this now when i clicked 3rd time it shows "sub" only i want add when i press 3rd time how can i do that
You haven't implemented the "verify the button name" part
how can i do it
Verify means: test what the current QPushButton text is and then set the other one.
with which function i can check the name of pushbutton i know i have to use it in If statement
Can u give on example related to my one.
Use the "text":http://qt-project.org/doc/qt-5/qabstractbutton.html#text-prop property
i wrote like this but it not working it not building the program
Thank you very much SGaist it worked