PDA

View Full Version : Moving (dragging) QTableView Columns



stefanadelbert
24th February 2010, 04:50
There is a function on Q3Table called setColumnMovingEnabled, which appears to allow/disallow columns from being repositioned. Is this possible and how is this achieved with a QTableView? Ideally I would like the user to be able to reposition columns and then save that column order so that it can persisted the next time the application is run.

ChrisW67
24th February 2010, 22:10
In short:
QHeaderView::setMovable() (http://doc.trolltech.com/latest/qheaderview.html#setMovable), QHeaderView::saveState() (http://doc.trolltech.com/latest/qheaderview.html#saveState) and QHeaderView::restoreState() (http://doc.trolltech.com/latest/qheaderview.html#restoreState)

Also, look at the answer to this question here:
http://www.qtcentre.org/threads/21225-QTableView-and-changing-row-order-in-model-by-dragging-them

stefanadelbert
24th February 2010, 22:35
That works exactly as required. Thanks.