How to disable drag&drop: QTreeView?
Simple application:
Code:
#include <QtGui>
int main(int argc, char *argv[])
{
model.
setHeaderData(0,Qt
::Horizontal,
QObject::tr("No."));
model.
setHeaderData(1,Qt
::Horizontal,
QObject::tr("Message"));
model.
setHeaderData(2,Qt
::Horizontal,
QObject::tr("Begin"));
model.
setHeaderData(3,Qt
::Horizontal,
QObject::tr("End"));
tree.setModel(&model);
tree.setColumnWidth(0,30);
tree.setColumnWidth(1,410);
tree.setColumnWidth(2,105);
tree.setColumnWidth(3,85);
tree.setRootIsDecorated(false);
tree.setAlternatingRowColors(true);
tree.setSortingEnabled(true);
tree.sortByColumn(2, Qt::DescendingOrder);
tree.show();
return app.exec();
}
I can't disable DnD for headers. I tried: setDragEnabled(false), setDragDropMode(QAbstractItemView::NoDragDrop) but to no avail. Could you comment?
Re: How to disable drag&drop: QTreeView?
You could use tree.header()->setMovable(false) to disable column "dragging".