This is kind of icky, but you could set a custom property on the button containing the row index it is in.
btnWidget->setProperty("TableRowIndex", rowIndex);
Then in the slot call sender()->property("TableRowIndex") to fetch the row index back out.
The drawback is anything that adds rows or removes rows from the table (or reorders them) will necessitate looping through the rows and resetting all the row indices.
What would be nice is if widgets that were attached to table cells simply had this property set and maintained automatically by the table widget itself--putting controls in rows of tables is hardly a unique activity, and it seems silly that everybody who uses one slot to accept signals from controls in multiple rows has to reinvent a solution. I guess if you need this solution in multiple places you could subclass QTableWidget itself and have it add and maintain this property.
-- C. Seggelin




Reply With Quote

Bookmarks