Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Move rows of Qtreeview up and down on button click
GAURAV PANT last edited by
I have a treeview and two buttons up and down.
Now on clicking up button the selected row should be moved up and similarly if down button is clicked then selected row should be moved down.
I have tried moveRow function but without any success.
stevenceuppens last edited by
QTreeWidgetItem* item = your_qtreewidget->currentItem();
int row = your_qtreewidget->currentIndex().row();
if (item && row > 0)
your_qtreewidget->insertTopLevelItem(row - 1, item);