Results 1 to 2 of 2

Thread: QTreeView: shift-click [+] decorator to fully expand branch

  1. #1
    Join Date
    Jun 2008
    Posts
    88
    Thanks
    4
    Thanked 4 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11
    Wiki edits
    1

    Default QTreeView: shift-click [+] decorator to fully expand branch

    I have a QTreeView with lots of branches representing some pretty deep hierarchies. I want to provide a way to expand the branch all the way to its leaves using the mouse and possibly a keyboard shortcut. Any ideas?

    Its the same behavior as hitting "*" (shift-8) on the currently selected branch only I want it to happen by clicking on the branch expansion decorator.

    I was thinking this would happen in the mousePressEvent and looking at the Qt source code could I use the same styleHint call to detect this? (expandOrCollapseItemAtPos is not available unfortunately but probably not necessary)

    Qt Code:
    1. void QTreeView::mousePressEvent(QMouseEvent *event)
    2. {
    3. Q_D(QTreeView);
    4. bool handled = false;
    5. if (style()->styleHint(QStyle::SH_Q3ListViewExpand_SelectMouseType, 0, this) == QEvent::MouseButtonPress)
    6. handled = d->expandOrCollapseItemAtPos(event->pos());
    7. if (!handled && d->itemDecorationAt(event->pos()) == -1)
    8. QAbstractItemView::mousePressEvent(event);
    9. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Sep 2015
    Posts
    3
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTreeView: shift-click [+] decorator to fully expand branch

    Any solution to this issue? I am facing an exact case problem. How do I detect if the decorator was clicked or the other parts of the QModelIndex?

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.