Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select Row in QTableView?

Tags:

qt

qtableview

I am new to QT, and I'm using QTableView, as shown below:

enter image description here

On the left side of the table, Qt is automatically showing a row number, as I've noted in red. How do I get rid of these numbers?

My other problem is, if I click any cell, only that cell is selected. How can I make it to where, when a user clicks a cell, the entire row is selected, like I noted in pink? For example, if I click the testApp-copy.itr cell then the entire third row should be selected.

like image 263
saravanan Avatar asked Oct 05 '10 06:10

saravanan


1 Answers

Use

table->verticalHeader()->hide();

to get the vertical header and hide it, and

table->setSelectionBehavior(QAbstractItemView::SelectRows);

to make QTableView only select whole rows. You may also want to specify the selection mode.

like image 115
Roman A. Taycher Avatar answered Sep 18 '22 19:09

Roman A. Taycher