Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.15.2, 6.0.0 RC2
-
None
-
Windows 10 Professional 64bit
Linux / KDE Plasma 5.20.3
Monitor 2560x1440 screen resolution
Description
QComboBox dimensions are fine on Windows using its standard "vista" style. It has the same item/menu height and font size like other similar control-widgets like QListWidget or QTreeWidget.
But QComboBox fusion style on Linux or Windows got much bigger overall dimensions than other similar control widgets like QListWidget or QTreeWidget. QComboBox item/menu height is much larger and its font is bigger.
This is not a scaling issue - it's the same with no scaling applied.
See screenshots of Windows and Linux example application below.
Because Windows and Linux are using different default fonts for correct comparison Roboto font is used (Qt 6.0 RC project attached below):
#include <QApplication> #include <QWidget> #include <QStringList> #include <QLabel> #include <QComboBox> #include <QListWidget> #include <QTreeWidget> int main(int argc, char *argv[]) { // Enable or disable for Qt 5.15.2 // QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling); // QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication a(argc, argv); // Enable or disable for Windows or Linux a.setStyle("fusion"); // a.setStyle("windowsvista"); a.setApplicationName("Linux Fusion Style"); QWidget w; QLabel labelCombo(&w); labelCombo.setFont(QFont("Roboto", 10)); labelCombo.setText("QComboBox"); labelCombo.setGeometry(22, 14, 130, 20); QLabel labelList(&w); labelList.setFont(QFont("Roboto", 10)); labelList.setText("QListWidget"); labelList.setGeometry(162, 14, 130, 20); QLabel labelTree(&w); labelTree.setFont(QFont("Roboto", 10)); labelTree.setText("QTreeWidget"); labelTree.setGeometry(312, 14, 130, 20); QStringList stringList; for (int i=1; i<=20; i++) { QString string = QString("Item%1").arg(i); stringList.append(string); } QComboBox combo(&w); combo.setFont(QFont("Roboto", 10)); combo.setGeometry(20, 41, 121, 26); combo.addItems(stringList); combo.setMaxVisibleItems(22); QListWidget list(&w); list.setFont(QFont("Roboto", 10)); list.setGeometry(160, 64, 121, 540); list.addItems(stringList); QTreeWidget tree(&w); tree.setFont(QFont("Roboto", 10)); tree.setHeaderLabel("Column 1"); tree.setGeometry(300, 42, 181, 562); tree.setColumnCount(1); QList<QTreeWidgetItem *> items; for (int i = 1; i <= 20; ++i) { items.append(new QTreeWidgetItem(static_cast<QTreeWidget *>(nullptr), QStringList(QString("item: %1").arg(i)))); } tree.insertTopLevelItems(0, items); w.resize(500,780); w.show(); return a.exec(); }