View Full Version : Getting row number in Qtablewidget
baluk
28th September 2010, 15:40
Hi,
I want to find the way to get the multiple selected row numbers (ex: 2nd and 3rd rows) in a table instead of how many rows are selected. Can any one please tell me the way.
Thank You,
Baluk
KTvsPeacock
28th September 2010, 16:53
for(short s=0; s < table->rowCount(); s++)
{
if(table->item(s,0)->isSelected())
{
qDebug()<<"Row "<<s<<"is selected!";
}
}
this would work, but there are better ways i think :D
baluk
29th September 2010, 08:48
Thnaks man. I got the other way around this problem. It works very fine.
QItemSelectionModel* selectionModel = ui->tableWidget->selectionModel();
QModelIndexList selected = selectionModel->selectedRows();
for(int i= 0; i< selected.count();i++)
{
QModelIndex index = selected.at(i);
qDebug() << index.row();
}
I got the code from one of the old posts in this forum.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.