Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-74582

Wrong style of QHeaderView

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P3: Somewhat important
    • None
    • 5.12.0, 5.15.2, 6.3.0
    • Widgets: Styles
    • None
    • macOS 10.14.3
    • macOS

    Description

      QHeaderView on macOS Mojave is too narrow and does not paint the top and bottom horizontal lines found on native tree views.

      A minimum working example in PySide2 is:

      import sys
      from PySide2 import QtWidgets
      
      app = QtWidgets.QApplication(sys.argv)
      
      tree_widget = QtWidgets.QTreeWidget()
      tree_widget.setColumnCount(3)
      
      layout = QtWidgets.QGridLayout()
      layout.addWidget(tree_widget)
      
      window = QtWidgets.QWidget()
      window.setLayout(layout)
      window.show()
      
      sys.exit(app.exec_())
      

      This can be fixed with the following style sheet, which gives approximately the right appearance: 

      QHeaderView {
         border: 1px solid rgb(183, 183, 183);
         background: rgb(240, 240, 240);
         border-left: 0px; border-right: 0px;
         font-size: 11pt;
      }

      QHeaderView::section {
         height: 18;
         border: 0px;
         background: rgb(240, 240, 240);
         padding-left: 10px;
      }

      QHeaderView::section:horizontal{
         margin-top: 3px;
         margin-bottom: 3px;
         border-right: 1px solid rgb(212, 212, 212);
      }

      Attachments

        1. correct_appearance.png
          correct_appearance.png
          544 kB
        2. qt_5_12_appearance.png
          qt_5_12_appearance.png
          447 kB
        3. qtreewidet_example.py
          0.3 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            tpochep Timur Pocheptsov
            samschott Sam Schott
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes