PDA

View Full Version : Getting the row for button pressed



steg90
28th November 2007, 16:35
Hi,

I've got a QTableView with five rows and five columns. In the fifth column of each row I have a QToolButton widget which is connected to the click signal and all go to the same slot. My problem is, I need to know which row is selected when the user has clicked on the button.



connect( button, SIGNAL(clicked()),this,SLOT(SendAMessage()) );




void CSignal::SendAMessage()
{
// how can I get which row is selected?

}


I cannot do this :



connect(ui.tableView, SIGNAL(clicked(QModelIndex)), this, SLOT(GetSelectedRow( QModelIndex )));


As the button click event is signalled first.

Any ideas?

Thanks,
Steve

jacek
28th November 2007, 16:42
See QItemSelectionModel. You can get one by calling QAbstractItemView::selectionModel(). Other solution is to use QSignalMapper.

steg90
28th November 2007, 16:45
Thanks Jacek, I will go take a look.