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. Having QML TreeView rows that fit contents

Having QML TreeView rows that fit contents

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
6 Posts 4 Posters 3.2k 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.
  • D Offline
    D Offline
    dzimiwine
    wrote on last edited by
    #1

    Hi,
    Is there a way to have rows in a QML TreeView to fit their contents when using itemDelegate or rowDelegate? Basically, I use a custom itemDelegate (Rectangle+Layout+Text+Image) but I cannot predetermine the height of each row as it depends on its contents.

    Regards,
    Dz

    p3c0P 1 Reply Last reply
    0
    • M Offline
      M Offline
      mstormer
      wrote on last edited by
      #2

      I am having the same problem. I would like to have text wrap and have the row height expand correctly to display the text based on the size of parent. if I have '\n' in the display text the row shows half of text from both lines. Is there a way using the delegates to tell the QML Treeview to adjust the height?

      1 Reply Last reply
      0
      • D dzimiwine

        Hi,
        Is there a way to have rows in a QML TreeView to fit their contents when using itemDelegate or rowDelegate? Basically, I use a custom itemDelegate (Rectangle+Layout+Text+Image) but I cannot predetermine the height of each row as it depends on its contents.

        Regards,
        Dz

        p3c0P Offline
        p3c0P Offline
        p3c0
        Moderators
        wrote on last edited by
        #3

        @dzimiwine For now you can make use of the private properties. Eg.

        TreeView {
           id: tree
           Component.onCompleted: {
               __currentRow = 0;
               var rowheight = tree.__currentRowItem.height
               console.log(rowheight)
           }
        }
        

        But note that these are still under development and hence its implementation or the property name itself may change in future.

        157

        M D 2 Replies Last reply
        0
        • p3c0P p3c0

          @dzimiwine For now you can make use of the private properties. Eg.

          TreeView {
             id: tree
             Component.onCompleted: {
                 __currentRow = 0;
                 var rowheight = tree.__currentRowItem.height
                 console.log(rowheight)
             }
          }
          

          But note that these are still under development and hence its implementation or the property name itself may change in future.

          M Offline
          M Offline
          mstormer
          wrote on last edited by
          #4

          @p3c0
          I can change the row height of a top level item, but I don't see how I can adjust the height for the children. Is there away using one of the delegates to change the row height of a child based it's Role?

          1 Reply Last reply
          0
          • p3c0P p3c0

            @dzimiwine For now you can make use of the private properties. Eg.

            TreeView {
               id: tree
               Component.onCompleted: {
                   __currentRow = 0;
                   var rowheight = tree.__currentRowItem.height
                   console.log(rowheight)
               }
            }
            

            But note that these are still under development and hence its implementation or the property name itself may change in future.

            D Offline
            D Offline
            dzimiwine
            wrote on last edited by
            #5

            @p3c0
            Thanks for your reply.
            I am not sure it is going to work as I need to do it for sub items. I will try few things and probably come back to you.

            BriginasB 1 Reply Last reply
            0
            • D dzimiwine

              @p3c0
              Thanks for your reply.
              I am not sure it is going to work as I need to do it for sub items. I will try few things and probably come back to you.

              BriginasB Offline
              BriginasB Offline
              Briginas
              wrote on last edited by Briginas
              #6
              This post is deleted!
              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