How to know which row of the QTableWidget has the focus
-
wrote on 4 Nov 2011, 11:39 last edited by
Is
@
tableWidget->currentRow()
@
what you're searching for? -
wrote on 7 Nov 2011, 05:04 last edited by
Hi Volker
How to do the same in case of QTableView.
-
wrote on 7 Nov 2011, 06:34 last edited by
You call QTableView::selectionModel(), and use the methods of the returned [[doc:QItemSelectionModel]]
-
wrote on 7 Nov 2011, 07:38 last edited by
Hi Andre
I did it like this & is working fine
QTableView::currentIndex().row();
-
wrote on 7 Nov 2011, 07:41 last edited by
Just hope that currentIndex() returns a valid index then...
-
wrote on 7 Nov 2011, 09:27 last edited by
Invalid indexes return -1 for row and column.
-
wrote on 7 Nov 2011, 10:34 last edited by
Ya Volker you are right but for that i have put conditional checking.
-
wrote on 8 Nov 2011, 07:38 last edited by
HI All
Is it possible to get row numbers created automatically on left side in QTableWidget.
How to get it? -
wrote on 8 Nov 2011, 15:24 last edited by
The vertical header is displayed by default. You can tweak it manually like this:
@
ui->tableWidget->horizontalHeader()->hide();
ui->tableWidget->verticalHeader()->show();
@If you do not provide other data, it is enumerated automatically, starting with 1, like in this screenshot of the Docs:
!/doc/qt-4.7/images/qtableview-resized.png!
-
wrote on 9 Nov 2011, 03:16 last edited by
Hi volker
Thanks for reply.
I want to know how to retrive these Numbers[1,2,3...] and store in some variable in case of QTableView.
-
wrote on 9 Nov 2011, 06:19 last edited by
You are confusing the matter again. Are you using QTableView or QTableWidget?
QTableWidget gives you accessor method to get the items representing the headers (if you set them, I'd think), while if you are using QTableView, you can use the model to find out the header contents as well. If you do just a little bit of searching in the documentation on a relevant term like "header" you will find them in no time flat.
I am wondering though: what is your goal? Why do you need to store the contents of the headers in some variables? It doesn't seem to make too much sense.
11/12