Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Change height of QML TreeView as it expands?
Forum Updated to NodeBB v4.3 + New Features

Change height of QML TreeView as it expands?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 1 Posters 683 Views 1 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.
  • fcarneyF Offline
    fcarneyF Offline
    fcarney
    wrote on last edited by
    #1

    Is there a way to have the QML TreeView change its height parameter as it expands to show more content?

    C++ is a perfectly valid school of magic.

    1 Reply Last reply
    0
    • fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by
      #2

      This looked promising, but it is not giving me good sizes:
      childrenRect
      "This read-only property holds the collective position and size of the item's children.
      This property is useful if you need to access the collective geometry of an item's children in order to correctly size the item."

      However the output of a console log is:

      QRectF(0,0,0,0)
      QRectF(0,0,100,0)
      

      C++ is a perfectly valid school of magic.

      1 Reply Last reply
      0
      • fcarneyF Offline
        fcarneyF Offline
        fcarney
        wrote on last edited by
        #3

        The best I can find is this:

        // 25 is a fudge value
        height: contentItem.childrend[0].childrenRect.height + 25
        

        This seems to expand the TreeView to the appropriate size.

        C++ is a perfectly valid school of magic.

        1 Reply Last reply
        0
        • fcarneyF Offline
          fcarneyF Offline
          fcarney
          wrote on last edited by
          #4

          Well, this is a mixed bag. If I use this and then scroll a listview that contains the treeview it causes the value to glitch out and start reporting different numbers. I suspect items are being dismissed in the background to save resources and being recreated. It may also be related to having multiple treeviews being scrolled over. Like if one it no longer visible it gets disabled. Not quite sure.

          C++ is a perfectly valid school of magic.

          1 Reply Last reply
          0
          • fcarneyF Offline
            fcarneyF Offline
            fcarney
            wrote on last edited by
            #5

            I have to say, that with all this effort to get treeview to behave it is not really doing what I want anyway. If you give a path to the QFileSystemModel and then hand this to the tree view it forces navigation of the entire path to get to the target directory:
            TreeViewNavigationProblems.png

            This is really annoying. I think with the problems I am having I may have to rewrite TreeView and hopefully not have to rewrite QFileSystemModel. I am just not sure where the path problem is yet. Argh!

            C++ is a perfectly valid school of magic.

            1 Reply Last reply
            1

            • Login

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