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):
Qt 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);To copy to clipboard, switch view to plain text mode
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:
I tried calling setAcceptDrops(true) on both the QTreeView/QTableView and on their QHeaderView, but this made no difference.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.
Bookmarks