Details
-
Bug
-
Resolution: Fixed
-
P3: Somewhat important
-
6.8.0
-
None
-
-
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(¢ral); }; 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
- duplicates
-
QTBUG-90641 QSpinBox widget height changes when a stylesheet is set even if it's invalid
-
- Closed
-
- resulted in
-
QTBUG-132431 Stylesheet Margin/Padding squashes QSpinBox
-
- Closed
-