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. QTreeWidget stylesheet - items padding
Forum Updated to NodeBB v4.3 + New Features

QTreeWidget stylesheet - items padding

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 2.2k 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.
  • D Offline
    D Offline
    Daniil S.
    wrote on last edited by
    #1

    I found a couple of options on the forums, but I still have not achieved that the content of the items and the header were aligned relative to the edge, say by 20 pixels, is it possible to do this through a stylesheet? I use qt 5.15.2 x32 on windows.
    First column looks nice, bat other without padding.

    47782a75-c3a6-4f33-8e3d-560ded4f75bc-image.png

    1 Reply Last reply
    0
    • JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by
      #2

      try QStyledItemDelegate to add margin

      D 1 Reply Last reply
      0
      • JoeCFDJ JoeCFD

        try QStyledItemDelegate to add margin

        D Offline
        D Offline
        Daniil S.
        wrote on last edited by
        #3

        @JoeCFD is it impossible to do it with stylesheet?

        1 Reply Last reply
        0
        • JoeCFDJ Offline
          JoeCFDJ Offline
          JoeCFD
          wrote on last edited by
          #4

          Try it to see if it works
          QTreeWidge::item
          {
          border: 0px;
          padding: 5px;
          }

          D 2 Replies Last reply
          0
          • JoeCFDJ JoeCFD

            Try it to see if it works
            QTreeWidge::item
            {
            border: 0px;
            padding: 5px;
            }

            D Offline
            D Offline
            Daniil S.
            wrote on last edited by Daniil S.
            #5

            @JoeCFD it certainly works, but not exactly how I want, i set padding-left: 20px, but first column has 40px;
            8e44e6a7-2b1a-46d7-bbd1-4402aec5f08f-image.png

            maybe "branch" affects?

            QTreeWidget {
            font-size: 12px;
            border: none;
            }
            
            QTreeWidget::item {
            height: 17px;
            padding-left: 20px;
            }
            
            QTreeView:indicator:!checked {
            width: 13px;
            height: 13px;
            }
            
            QTreeView:indicator:checked {
            width: 15px;
            height: 15px;
            image: url(:/images/checked.png);
            }
            
            QHeaderView::section {
            text-align: left;
            height: 25px;
            padding-left: 20px;
            }
            
            1 Reply Last reply
            0
            • JoeCFDJ JoeCFD

              Try it to see if it works
              QTreeWidge::item
              {
              border: 0px;
              padding: 5px;
              }

              D Offline
              D Offline
              Daniil S.
              wrote on last edited by
              #6

              @JoeCFD if i remove "checked" stylesheet
              43348e96-913e-4079-8c18-c054edd10952-image.png

              under the selected (light green) item, hovered item

              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