I have created a table using qtablewidget. The table contains a few buttons. I have connected click event for those buttons with a function. Problem is, I want know row and col of button which is sending the click event. I.E. when user is clicking a button, i want to know it's position in the table. How do i do that?
1
votes
2 Answers
3
votes
If you have some way to differentiate between the buttons themselves, you can call
QObject* senderButton = Sender();
from within the slot that is receiving the signal to get a pointer to the object that sent the signal (http://doc.trolltech.com/4.7/qobject.html#sender).
Otherwise you may want to look at
QSignalMapper
There is an example here: http://doc.trolltech.com/4.7/signalsandslots.html#advanced-signals-and-slots-usage
0
votes
You would probably need to connect cellClicked signal from QTableWidget to get the row and column of the cell. You will probably need to test which order the signals would be emitted to know whether or not you will need to emit the signal for button or just call the handler for that signal straight up.