Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
6.7.0
-
None
-
Windows 11
-
-
b457376c0 (dev), 495e5cbbb (6.7)
Description
The width (size hint) of QSpinBox is too small, if the application style is set to Windows 11. If the style is changed to Windows the calculation is done correct.
The problem is also true for other widgets derived from QAbstractSpinBox (e.g. QDateTimeEdit).
#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); hLayout.addWidget(&sb); hLayout.addWidget(&sbNoButton); 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 << " 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; QHBoxLayout hLayout; QVBoxLayout vLayout; QTextEdit debug; QWidget central; }; int main(int argc, char *argv[]) { //QApplication::setStyle(QStyleFactory::create("Windows")); QApplication::setStyle(QStyleFactory::create("windows11")); QApplication a(argc, argv); MainWindow w; //w.setWindowTitle("Windows Style"); w.setWindowTitle("Windows 11 Style"); w.show(); return a.exec(); }