Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change order of columns in QTableView

Tags:

c++

qt

qtableview

I wanted to know how we can change the order of columns in QtableView by dragging ? I currently have a class derived from FilterProxyModel as source to QtableView. I am using QT 4.8

like image 547
MistyD Avatar asked Sep 17 '13 16:09

MistyD


People also ask

How do you change column arrangements?

To change the column order In Object Explorer, right-click the table with columns you want to reorder and select Design. Select the box to the left of the column name that you want to reorder. Drag the column to another location within the table.


1 Answers

Qt 5.x:

ui->tableView->horizontalHeader()->setSectionsMovable(true);

QHeaderView::setSectionsMovable()

Qt 4.x:

ui->tableView->horizontalHeader()->setMovable(true);

QHeaderView::setMovable()

like image 174
Chris Avatar answered Sep 30 '22 06:09

Chris