Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QTreeView expand/collapse indicator disappears

QTreeView expand/collapse indicator disappears

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
12 Posts 4 Posters 3.3k Views 2 Watching
  • 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.
  • V Offline
    V Offline
    vdevadass
    wrote on last edited by vdevadass
    #1

    Hi,

    I set the following stylesheet for the QTreeView:

    QTreeView::branch:has-children:!has-siblings:closed, QTreeView::branch:closed:has-children:has-siblings
    {
    image: url(:/Images/tree-collapsed);
    }
    QTreeView::branch:open:has-children:!has-siblings, QTreeView::branch:open:has-children:has-siblings
    {
    image: url(:/Images/tree-expanded);
    }
    

    Scenario:

    Root
    --|-B
    ---- |
    +C
    ---- |_ -D

    1. Expand until a branch, D. The D branch is unable to get it's children, now collapse the parent branch, B.
    2. When we expand parent B again, the D branch does not have the expand/collapse button.

    I need the button to stay with the branches always.
    Why is the button being removed and how to retain the expand/collapse indicator?

    Thanks.

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

      Hi,

      Why is the branch D unable to get its children ?
      What version of Qt ?
      What platform ?

      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
      • V Offline
        V Offline
        vdevadass
        wrote on last edited by
        #3

        The branch children are being requested from another system on the network.
        Hence, if the system is not up, we are unable to get the list of children.

        Qt 4.8
        Platform: Embedded

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

          Then it make sense that it can't show anything since it can't retrieve any information.

          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
          • V Offline
            V Offline
            vdevadass
            wrote on last edited by
            #5

            @SGaist said in QTreeView expand/collapse indicator disappears:

            hat it can't show anything since it can't retrieve any information

            Right. But i would like the expand/collapse to remain.
            In case the other system comes up, i can't expand this branch anymore since the indicator is not there.

            I would need to go to a different view and come back for it to display the indicator again.

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

              Then you have to provide a "fake" model entry that represents the data that should arrive.

              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
              • V Offline
                V Offline
                vdevadass
                wrote on last edited by
                #7

                Then each branch may need a fake model entry.

                Is there another solution?

                raven-worxR 1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  What kind of other solution do you have in mind ? If your model doesn't have the data for some reason, either you provide a mean to tell the user that the data is coming and trigger an update when it's really there or you don't show anything until the data has arrived and then trigger an update of the view.

                  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
                  • V vdevadass

                    Then each branch may need a fake model entry.

                    Is there another solution?

                    raven-worxR Offline
                    raven-worxR Offline
                    raven-worx
                    Moderators
                    wrote on last edited by raven-worx
                    #9

                    @vdevadass
                    a treeview shows an expand indicator when the model's rowCount() method returns a value > 0 or if it's canFetchMore() method returns true.
                    So delayed loading should be implemented via the canFetchMore() and fetchMore() methods of the model.

                    --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                    If you have a question please use the forum so others can benefit from the solution in the future

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

                      @raven-worx from my understanding, the data was already there or at least part of it available at some point. I'm not sure that canFetchMore() and fetchMore() would be of use in this case. But they sure would be when starting to load the data.

                      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
                      • V vdevadass

                        Hi,

                        I set the following stylesheet for the QTreeView:

                        QTreeView::branch:has-children:!has-siblings:closed, QTreeView::branch:closed:has-children:has-siblings
                        {
                        image: url(:/Images/tree-collapsed);
                        }
                        QTreeView::branch:open:has-children:!has-siblings, QTreeView::branch:open:has-children:has-siblings
                        {
                        image: url(:/Images/tree-expanded);
                        }
                        

                        Scenario:

                        Root
                        --|-B
                        ---- |
                        +C
                        ---- |_ -D

                        1. Expand until a branch, D. The D branch is unable to get it's children, now collapse the parent branch, B.
                        2. When we expand parent B again, the D branch does not have the expand/collapse button.

                        I need the button to stay with the branches always.
                        Why is the button being removed and how to retain the expand/collapse indicator?

                        Thanks.

                        raven-worxR Offline
                        raven-worxR Offline
                        raven-worx
                        Moderators
                        wrote on last edited by raven-worx
                        #11

                        @SGaist said in QTreeView expand/collapse indicator disappears:

                        from my understanding, the data was already there or at least part of it available at some point.

                        i understood that differently, due to the following comments:

                        Expand until a branch, D. The D branch is unable to get it's children, now collapse the parent branch, B.

                        The branch children are being requested from another system on the network.
                        Hence, if the system is not up, we are unable to get the list of children.

                        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                        If you have a question please use the forum so others can benefit from the solution in the future

                        1 Reply Last reply
                        0
                        • H Offline
                          H Offline
                          hansie
                          wrote on last edited by
                          #12

                          @vdevadass said in QTreeView expand/collapse indicator disappears:

                          l

                          QTreeView::branch:closed:adjoins-item:has-children {
                          image: url(:/Images/tree-collapsed);
                          }

                          QTreeView::branch:open:adjoins-item {
                          image: url(:/Images/tree-expanded);
                          }

                          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