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. [SOLVED] Row height in QTreeView
Qt 6.11 is out! See what's new in the release blog

[SOLVED] Row height in QTreeView

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 10.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.
  • R Offline
    R Offline
    rubikon
    wrote on last edited by
    #1

    Hello.

    I've created an a TreeModel with a TreeView. But as it can be seen on the picture at the bottom the Row height is higher than it needs to be.

    How can I resize the row height to the height of the content like it is done with ui->treeView->header()->setResizeMode(QHeaderView::ResizeToContents); for the column width?

    !http://s3.imgimg.de/uploads/01557c97e3png.png(here)!

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Sam
      wrote on last edited by
      #2

      The image is not visible : Kindly update.

      One way of setting the row height is to write a delegate and override sizeHint() function where you can specify the width and height for the row.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rubikon
        wrote on last edited by
        #3

        [quote author="Sam" date="1352889258"]The image is not visible : Kindly update.
        [/quote]

        Strange. I can see the image. Maybe this link works:http://s3.imgimg.de/uploads/01557c97e3png.png

        [quote author="Sam" date="1352889258"]
        One way of setting the row height is to write a delegate and override sizeHint() function where you can specify the width and height for the row.[/quote]

        Is this the only way? I haven't used own delegates yet :-)

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on last edited by
          #4

          THe interesting question is: why is the row height this high! Typically, it is as high as one line.
          Is thee some multiline elements in the tree?

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          1 Reply Last reply
          0
          • R Offline
            R Offline
            rubikon
            wrote on last edited by
            #5

            Good hint.

            There were linebreaks at the end of the strings I've read from a file :-/

            After removing them everything looks fine.

            Thank you very much.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              Sam
              wrote on last edited by
              #6

              bq. Strange. I can see the image. Maybe this link works:http://s3.imgimg.de/uploads/01557c97e3png.png

              I figured out the the url link in blocked by the provider in my country. So the image as well as the link both does not open for me. Anyhow i used tor browser to view the image :D

              @Gerolf +1 for that :)

              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