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. How to remove padding on columns QTreeview
Forum Updated to NodeBB v4.3 + New Features

How to remove padding on columns QTreeview

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 321 Views
  • 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.
  • T Offline
    T Offline
    Tater
    wrote on last edited by
    #1

    6a88c5e1-d037-48c7-bead-501ce073c9c8-image.png

    As you can see in my picture I have two columns the first column has padding on the right of the pixmap and the second column has padding on the right of the pixmap. These are both pixmaps that are DecorationRoles that are scaled from 64x64 to 16x16.

    This is how I try to resize the columns currently:

        this->header()->setSectionResizeMode(QHeaderView::Fixed);
        this->resizeColumnToContents(0);
        this->resizeColumnToContents(1);
    

    I have no padding added on my QSS

    C 1 Reply Last reply
    0
    • T Tater

      6a88c5e1-d037-48c7-bead-501ce073c9c8-image.png

      As you can see in my picture I have two columns the first column has padding on the right of the pixmap and the second column has padding on the right of the pixmap. These are both pixmaps that are DecorationRoles that are scaled from 64x64 to 16x16.

      This is how I try to resize the columns currently:

          this->header()->setSectionResizeMode(QHeaderView::Fixed);
          this->resizeColumnToContents(0);
          this->resizeColumnToContents(1);
      

      I have no padding added on my QSS

      C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      @Tater The space is for the text of the DisplayRole you are not providing, and is at least as big as the section width. Start by looking at the QHeaderView::minimumSectionSize(). If you want to provide a completely custom rendering for the items then you probably need to roll your own QStyledItemDelegate.

      1 Reply Last reply
      2

      • Login

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