View Full Version : SelectionModel

29th November 2007, 10:49

I'm using QItemSelectionModel and setting this in my QTableView. My QTableView has a number of rows, but in the fifth column of each row it has a QToolButton. I have set up a signal for when the user clicks the button and within that signal I have the following code :

QModelIndex s = m_pselectionModel->currentIndex();

Now I thought this would give me the row number for which the button that was clicked on actually resides in, but it doesn't, it only does this if I highlight one of the other columns within the QTableView. Is there a way of doing this?


29th November 2007, 12:30
If you have set a widget using setIndexWidget() then you need to get the proper index using indexWidget() - for example by iterating over indexes and comparing their indexWidget pointers to your button. Or use a QSignalMapper or don't use index widgets but instead use the delegate approach.

29th November 2007, 13:27

I've gone down the QSignalMapper route and it works a treat.