PDA

View Full Version : QTableView and changing row order in model by dragging them



YaK
23rd May 2009, 05:22
I need to change order of data elements themselves. How can i do this?

wysota
24th May 2009, 11:55
Enable "InternalMove" dragDropMode for the view.

stefanadelbert
24th February 2010, 06:20
Enabling "InternalMove" does not make it possible to change the order of elements in a table. In fact it seems to have no effect whatsoever.

I have a custom model (inherited from QAbstractListModel) and use a QTableView to view the data. I would like to be able to reorder the columns by dragging and dropping them.

Does anyone know how to achieve this?

wysota
24th February 2010, 11:12
Enabling "InternalMove" does not make it possible to change the order of elements in a table. In fact it seems to have no effect whatsoever.
Did you implement means for changing the model (i.e. setData(), insertRows(), removeRows())?

ChrisW67
24th February 2010, 23:00
I have a custom model (inherited from QAbstractListModel) and use a QTableView to view the data. I would like to be able to reorder the columns by dragging and dropping them.

If you want the column (row) display order to be changeable by drag and drop of the column (row) headers then you need to look at QHeaderView::setMovable(). Wysota's suggestion is to do with moving data about within the model underlying the view (using drag and drop on the view).

wysota
25th February 2010, 18:29
I was addressing the "changing row order in model" issue.