QTreeView not showing headers after overriding
Solved
General and Desktop
-
Hi guys, I am facing the following issue :
I wanted to disable dragging on my QTreeView. For that, I have created a custom TreeView overriding mousemoveEvent that works well :
TreeView::TreeView(QWidget *parent) :QTreeView(parent) { } void TreeView::mouseMoveEvent(QMouseEvent *event){ if(state() == DraggingState || state() == DragSelectingState || state() == ExpandingState){ return; } }
But after doing that, my TreeView is not showing the header anymore. The header was only shown using QTreeView. What did I miss ?
-
Hi
Whats wrong with setAcceptDrops(false); ?
or
setDragDropMode(QAbstractItemView::NoDragDrop);
(if its to prevent internal reordering)Well one thing that could be messing with the headers is that you
dont call QTreeView::mouseMoveEvent(event);
To let base class do what it normally does so that might break things.void TreeView::mouseMoveEvent(QMouseEvent *event){ if(state() == DraggingState || state() == DragSelectingState || state() == ExpandingState){ return; } QTreeView::mouseMoveEvent(event); }