Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTreeView with valid setAutoExpandDelay to Only do expand, and never do collapse for already expanded items.
Forum Update on Monday, May 27th 2025

QTreeView with valid setAutoExpandDelay to Only do expand, and never do collapse for already expanded items.

Scheduled Pinned Locked Moved Solved General and Desktop
qtreeviewexpandcollapseautoexpanddelay
5 Posts 3 Posters 863 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jammin44fm
    wrote on last edited by
    #1

    Hi everyone,

    I have a class that extends QTreeView and I have enabled the auto expand functionality via the mouse Hover,
    by setting the autoExpandDelay(500);
    This works to have the folders auto-expand as expected, However it also does the reverse to an already expanded dir.
    ie. it collapses that dir.

    Ideally I would like to make it so that the autoExpand function never triggers a collapse();
    Is this possible?

    I have tried to extend the expand() and collapse() slots, but they are not virtual in the QTreeView base class :(

    My only other option is not to enable the autoExapnd functionality and try and provide that myself,
    but I am not too confident about doing that - especially in a performant manner.

    Cheers,

    James
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      AFAIK, no it's not, the animated property documentation explicitly says it applies to both. The implementation of QTreeView confirms this. It happens in the private implementation of the class.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Jammin44fm
        wrote on last edited by
        #3

        I've managed to hack together my own solution,
        (based on looking at the source )

        Using my own QBasicTimer, and overriding the
        void timerEvent(QTimerEvent *event) and
        void dragMoveEvent(QDragMoveEvent *event)

        it's a bit ugly but it works.
        it would be nice if the default mechanism offered the option to make the time expand only.

        Cheers,

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DavidFaure
          wrote on last edited by DavidFaure
          #4

          @SGaist I don't see the relation with the animated property, which is about an animation on expand/collapse (including when the user manually clicks on an item). autoExpandDelay() is about drag-n-drop only. This discussion is basically https://bugreports.qt.io/browse/QTBUG-2553

          1 Reply Last reply
          1
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            I may have misread the code back then but nice that you are taking care of it.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved