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

Setting style to QTableWidget header before show() doesn’t work for the horizontal header

    XMLWordPrintable

    Details

    • Commits:
      9ea9ec1cbb567197ce0bf44ea58a79308c9b64d8

      Description

      If a stylesheet defines the appearance for QHeaderView::section and it’s set for a QTableWidget before the widget is shown, the style is not applied to the horizontal header. The style is correctly set to the vertical header.

      Setting the same stylesheet to the application or the horizontal header before showing the table widget works. Also setting the style to QTableWidget after the show() works correctly.

      The code below shows this issue:

      int main(int argc, char *argv[]) {
          QApplication app(argc, argv);
          QString qss = "QHeaderView::section{color: rgb(255, 255, 255);background-color: rgb(0, 0, 0);}";
       
          QTableWidget t1(10,10,NULL);
          QTableWidget t2(10,10,NULL);
          t1.setWindowTitle("t1");
          t2.setWindowTitle("t2");
      
          t1.setStyleSheet(qss);
          t1.show();
          t2.show();
          t2.setStyleSheet(qss);
      
          return app.exec();
      }
      

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            • Assignee:
              andysh Andy Shaw
              Reporter:
              qtcomsupport Qt Support
            • Votes:
              2 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Gerrit Reviews

                There are no open Gerrit changes