PDA

View Full Version : learn row of qtablewidget



ahmetturan
12th February 2012, 19:39
i add pushbutton to qtablewidget with this code:


QPushButton *btn=new QPushButton();
ui->tableWidget->setCellWidget(currentRow,0,btn);
when i click the button how can i learn its row?
ui->tableWidget->row(btn) does not work. because btn is not qtablewidgetitem

KillGabio
12th February 2012, 19:50
isn`t currentRow???

I usually do this when adding an item to the table: first get the rowCount of the table, then add a row with that number...so that way you insert at the end and you know the rowNum to use it for future usage.

ahmetturan
12th February 2012, 20:13
for example i have ten rows in my tablewidget and one button for each rows (total ten buttons).
when i click button in fifth row, how can i learn row number?

KillGabio
12th February 2012, 20:56
Have a look at this class: http://developer.qt.nokia.com/doc/qt-4.8/QItemSelectionModel.html

norobro
12th February 2012, 20:59
Here you go: link (http://www.qtcentre.org/threads/38904-Qpushbutton-clicked%28%29?highlight=qpushbutton)