Re: Autoscroll TableView when Dragging Column
I would like to be able to have a QTableView or QTreeView autoscroll when a column is dragged to either the far left or far right of the viewport.
This is how I'm currently creating and setting up a QTreeView (in a custom widget):
Code:
// model = ...
treeView->setModel(model);
treeView->setFocusPolicy(Qt::NoFocus);
treeView->setAlternatingRowColors(true);
treeView->setAllColumnsShowFocus(true);
treeView->setSortingEnabled(false);
treeView->setUniformRowHeights(true);
treeView->header()->setDefaultAlignment(Qt::AlignCenter);
treeView->header()->setDefaultAlignment(Qt::AlignHCenter);
treeView->header()->setHighlightSections(false);
treeView->header()->setMovable(true);
treeView->header()->setStretchLastSection(true);
I've tried setting AutoScroll, which made no difference (expected since AutoScroll==true by default).
Is this actually an available feature of the QAbstractItemView or do I need to implement this behaviour myself?
Added after 21 minutes:
Based on Qt 4.7.2 documentation:
Quote:
autoScroll : bool
This property holds whether autoscrolling in drag move events is enabled.
If this property is set to true (the default), the QAbstractItemView automatically scrolls the contents of the view if the user drags within 16 pixels of the viewport edge. If the current item changes, then the view will scroll automatically to ensure that the current item is fully visible.
This property only works if the viewport accepts drops. Autoscroll is switched off by setting this property to false.
I tried calling setAcceptDrops(true) on both the QTreeView/QTableView and on their QHeaderView, but this made no difference.
Re: Autoscroll TableView when Dragging Column
Surely someone must have wanted this to work at some point. The viewport of a QTableView and QTreeView supports autoscroll for drag and drop, so surely there is support for dragging of column headers too. Anyone?
Re: Autoscroll TableView when Dragging Column
I'm having the same problem, although this is nearly a year later... anybody see this same thing? Anybody? I'm also using 4.7.2. It would be nice to autoscroll on dragging.
Re: Autoscroll TableView when Dragging Column