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

Incorrect QAbstractSpinBox size hint in Windows 11 style when style sheet is set

    XMLWordPrintable

Details

    • Windows
    • 96adebed6 (dev), 168f4aee2 (6.8), b2cc8824e (dev), e23933e86 (6.9), 75fd0f3ba (6.8)

    Description

      This is essentially the same as QTBUG-124150, but the problem still manifests whenever the spin box inherits any non-trivial style sheet. For example, see the sample code from that issue with a style sheet set on the application:

      #include <QApplication>
      #include <QtWidgets>
      
      class MainWindow : public QMainWindow
      {
      public:
          MainWindow(QWidget *parent = nullptr) : QMainWindow{parent} {
              sb.setMaximum(99999);
              sb.setValue(12345);
      
              sbNoButton.setMaximum(99999);
              sbNoButton.setValue(12345);
              sbNoButton.setButtonSymbols(QAbstractSpinBox::NoButtons);
      
              sbSuffix.setMaximum(99999);
              sbSuffix.setValue(12345);
              sbSuffix.setSuffix(" units");
      
              hLayout.addWidget(&sb);
              hLayout.addWidget(&sbNoButton);
              hLayout.addWidget(&sbSuffix);
              hLayout.addStretch(1);
      
              vLayout.addLayout(&hLayout);
              vLayout.addWidget(&debug);
      
              central.setLayout(&vLayout);
              setCentralWidget(&central);
          };
      protected:
          void resizeEvent(QResizeEvent *event) override {
              debug.clear();
              QString s;
              QDebug out{&s};
              out << " qt version:\t" << QT_VERSION_STR << "\n";
              out << "style:\t" << QApplication::style()->objectName() << "\n";
              out << "sb size: \t" << sb.size()
                  << "\t sbNoButton size: \t" << sbNoButton.size() << "\n";
              out << "sb hint: \t" << sb.sizeHint()
                  << "\t sbNoButton hint: \t" << sbNoButton.sizeHint() << "\n";
              out << "sb min. hint: \t" << sb.minimumSizeHint()
                  << "\t sbNoButton min. hint: \t" << sbNoButton.minimumSizeHint() << "\n";
              out << "sb min.: \t" << sb.minimumSize()
                  << "\t sbNoButton min.: \t" << sbNoButton.minimumSize() << "\n";
      
              debug.append(s);
              QMainWindow::resizeEvent(event);
          };
      private:
          QSpinBox sb;
          QSpinBox sbNoButton;
          QSpinBox sbSuffix;
          QHBoxLayout hLayout;
          QVBoxLayout vLayout;
          QTextEdit debug;
          QWidget central;
      };
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          a.setStyleSheet("QTooltip { background: red }");
      
          MainWindow w;
          w.setWindowTitle("Style Test");
          w.show();
          return a.exec();
      }
      

      Adding the style sheet breaks the size hint again.

      Attachments

        Issue Links

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

          Activity

            People

              chehrlic Christian Ehrlicher
              jasonhaslam Jason Haslam
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews