[Solved] How to Toggle qpushbutton name
-
-
Hi,
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()));void abcd:slotButtonaddPressed()
{
hideButton->setText(tr("sub"));
}
@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
thanks -
You haven't implemented the "verify the button name" part
-
Verify means: test what the current QPushButton text is and then set the other one.
-
Use the "text":http://qt-project.org/doc/qt-5/qabstractbutton.html#text-prop property