PDA

View Full Version : SelectionModel



steg90
29th November 2007, 11:49
Hi,

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?

Regards,
Steve

wysota
29th November 2007, 13: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.

steg90
29th November 2007, 14:27
Thanks,

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