Move rows of Qtreeview up and down on button click
-
Hi,
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.
Kindly Help.
-
Hey,
@
QTreeWidgetItem* item = your_qtreewidget->currentItem();
int row = your_qtreewidget->currentIndex().row();if (item && row > 0)
{
your_qtreewidget->takeTopLevelItem(row);
your_qtreewidget->insertTopLevelItem(row - 1, item);
your_qtreewidget->setCurrentItem(item);
}
@src: http://stackoverflow.com/questions/2035932/raise-and-lower-qtreewidgetitem-in-a-qtreewidget