Results 1 to 4 of 4

Thread: Autoscroll TableView when Dragging Column

  1. #1
    Join Date
    Feb 2010
    Location
    Sydney, Australia
    Posts
    111
    Thanks
    18
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default 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):

    Qt Code:
    1. treeView = new QTreeView(this);
    2. // model = ...
    3. treeView->setModel(model);
    4. treeView->setFocusPolicy(Qt::NoFocus);
    5. treeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
    6. treeView->setAlternatingRowColors(true);
    7. treeView->setAllColumnsShowFocus(true);
    8. treeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
    9. treeView->setSelectionBehavior(QAbstractItemView::SelectRows);
    10. treeView->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
    11. treeView->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
    12. treeView->setSortingEnabled(false);
    13. treeView->setUniformRowHeights(true);
    14.  
    15. treeView->header()->setDefaultAlignment(Qt::AlignCenter);
    16. treeView->header()->setDefaultAlignment(Qt::AlignHCenter);
    17. treeView->header()->setHighlightSections(false);
    18. treeView->header()->setMovable(true);
    19. 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:

    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.
    Last edited by stefanadelbert; 21st June 2011 at 03:11.

  2. #2
    Join Date
    Feb 2010
    Location
    Sydney, Australia
    Posts
    111
    Thanks
    18
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default 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?

  3. #3
    Join Date
    Sep 2012
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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.

  4. #4
    Join Date
    May 2007
    Posts
    90
    Thanks
    40
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Autoscroll TableView when Dragging Column

    post removed
    Last edited by TheGrimace; 13th November 2012 at 20:29.

Similar Threads

  1. Replies: 0
    Last Post: 18th April 2011, 16:07
  2. autoscroll on drag
    By Michael_Levin in forum Newbie
    Replies: 0
    Last Post: 17th January 2011, 23:09
  3. Autoscroll in Tableview
    By codeman in forum Qt Programming
    Replies: 0
    Last Post: 13th January 2011, 13:54
  4. Tableview - Three subcolumns inside one column?
    By qlands in forum Qt Programming
    Replies: 2
    Last Post: 24th March 2010, 16:04
  5. Autoscroll in ScrollArea
    By BalaQT in forum Qt Programming
    Replies: 2
    Last Post: 26th October 2009, 06:37

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.