How can find which button is clicked.
Hi
How i can identify which button is clicked. I have three buttons connected to the same slot and in this slot i want to handle all three buttons difeerently. isClicked() something like this can solve my problem but i have not find this property.
How i can handle buttons then , i change the background color on clicking and i want that this remain untill another button is not clicked.
Re: How can find which button is clicked.
You can either use QSignalMapper, or get the emitter's handle using sender() call in the slot, I would prefer the first one.
Re: How can find which button is clicked.
Thanks for reply but i have solve the problem.
But the background color is not remaining untill another button is clicked. How should do it.
Re: How can find which button is clicked.
Quote:
But the background color is not remaining untill another button is clicked. How should do it.
It's not clear what to you said, but I guess you may changing the color some were else, or the slots are being called again
Re: How can find which button is clicked.
If you want to do something different for each button, this argues for having three different slots.
Re: How can find which button is clicked.
If you have 3 buttons and each one changes the background to a different colour this sounds like a good situation to put the buttons in a QButtonGroup. The QButtonGroup::clicked signal passes a pointer or id to let you know which button was clicked.
http://doc.qt.nokia.com/4.7/qbuttongroup.html
You can add buttons to a QButtongroup via the designer by having all your buttons selected at once and then right clicking.