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 branch rendering
Forum Updated to NodeBB v4.3 + New Features

QTreeView branch rendering

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.6k 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.
  • J Offline
    J Offline
    jsshapiro
    wrote on last edited by
    #1

    One of the stylesheet "examples":http://doc.qt.nokia.com/4.7-snapshot/stylesheet-examples.html#customizing-qtreeview suggests using png files to implement vertical and horizontal lines in QTreeView.

    It's a very old approach, and a bad one, because the height of the elements in the tree view is variable. Something as simple as using a different font or a different screen resolution makes those images the wrong height. So either the images get stretched, and look awful, or they don't get stretched, and look even worse. It's one of those things that really wants to be rendered dynamically.

    Does anybody know a good (i.e. properly scaling) approach for doing this, or do I need to specialize QTreeView myself?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      -You could subclass the delegate and do your own rendering there.-
      Note that I find your example a bit artificial. If you go around messing with style sheets to style this aspect of the tree view, then I think it is reasonable to assume that you also control the fontsize and other size aspects of the tree view.

      -Still, the delegate approach is more flexible.-

      Edit:
      Branches are not rendered by the delegate, but by the tree view. Sorry! It seems that indeed you will need to subclass either the QTreeView, or perhaps use a proxy style.

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

        Indeed. And it wasn't that I wanted to be messing around with style sheets. It was rather the case that style sheets seemed to be the "suggested" way to make the tree view draw its branches. If there is a better/simpler way to get that, I'm all in favor of it!

        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