PDA

View Full Version : Want to move a column in QtableWidget from Ist to Second position using mouse



Player
14th July 2011, 10:48
Hi All,
I want to know ...how to move a column in QTableWidget from Position 1 to position 2 using mouse..

I tried with the following function , but it was not working ..

tableWidget.setDragDropOverwriteMode(true);
tableWidget.setDragEnabled(true);
tableWidget.setDragDropMode(QAbstractItemView::Int ernalMove);
tableWidget.setSelectionBehavior(QAbstractItemView ::SelectRows);

Santosh Reddy
20th July 2011, 07:00
You need to set the sections as movable in horizontal header (i.e. QHeaderView) of the QTableWidget


QTableWidget * table = new QTableWidget(this); // or QTableView
table->horizontalHeader()->setMovable(true);

QTreeWidget * tree = new QTreeWidget(this); // or QTreeView
tree->header()->setMovable(true);