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. Removing Separators from QHeaderView
Forum Updated to NodeBB v4.3 + New Features

Removing Separators from QHeaderView

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 2.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.
  • M Offline
    M Offline
    Mario84
    wrote on last edited by
    #1

    Hello everybody.

    I am using a QTreeview with multiple columns in one of our projects.
    In this TreeView, some columns build a logical group and I just wondered if there is a way to eliminate the separator between those grouped columns (resizing them is already deactivated). Having the separator shown isn't a big problem, it just looks ugly ;)
    Important is, that the separators shouldn't be removed for all columns, but only for specific ones...

    I guess the best solution would be to display the information of those grouped columns in a delegate and actually make it a single column, but this would cause quite a lot of refactoring work, which unfortunately is no option...

    Does anyone know another way to do this?

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

      You'd have to subclass QTreeView. I think, that you'll have to reimplement the drawRow method, but I'm not certain of that. Alternatively, it should be doable via the style. Both would probably require some digging into the Qt sources to find the best place to do this.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Mario84
        wrote on last edited by
        #3

        [quote author="Andre" date="1363290926"]You'd have to subclass QTreeView.[/quote]

        It's only the header I want to remove the separators from, so I guess subclassing QHeaderView would be correct...
        I already thought about doing so and overwriting drawSection(), but as I'm not that familiar with drawing, this wouldn't probably be less work than the delegate idea ;)

        I'd prefer a solution via stylesheets... but I guess that's not possible!?

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

          Ah, sorry, yes. I thought you wanted to remove the separators in the view itself.
          Using a delegate in QHeaderView is not possible.

          from the documentation:
          [quote]Note: Each header renders the data for each section itself, and does not rely on a delegate. As a result, calling a header's setItemDelegate() function will have no effect.[/quote]

          Doing your own rendering shouldn't be all that hard though. You can rely on QStyle to do most of the hard work for you. You should be able to use QStyle::drawControl(CE_HeaderSection, ...) to do the rendering of a section of an item.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Mario84
            wrote on last edited by
            #5

            My idea was not to use a delegate in the headerview, but in the treeview, making the columns i want to group a single one -> then I'd not encounter the separator problem... but as I mentioned, this would cause too much refactoring work...

            I'll have a look at QStyle...

            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