Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
6.9.0
-
None
Description
I'm setting app attribute Qt::AA_Use96Dpi (historically, to make some controls bigger, can't remember why I added it at some point).
When this attribute is set, the font menu of the app is made smaller when a QLineEdit is created somewhere. It's wierd, but this is what I observed.
Here is the sample program I use:
#include <QApplication> #include <QMainWindow> #include <QPushButton> #include <QMenu> #include <QVBoxLayout> #include <QLineEdit> int main( int argc, char* argv[] ) { // https://bugreports.qt.io/browse/QTBUG-136641 // without this line menu size is always OK QApplication::setAttribute(Qt::AA_Use96Dpi); QApplication app(argc, argv); QMainWindow wnd; QWidget* centralWidget = new QWidget(&wnd); centralWidget->setLayout(new QVBoxLayout); QMenu* menu = new QMenu(""); menu->addAction("Hello"); auto button = new QPushButton("Hello"); button->setMenu(menu); centralWidget->layout()->addWidget(button); // When Qt::AA_Use96Dpi is used, creating a QLineEdit make menu font smaller // When Qt::AA_Use96Dpi is used, menu font size is OK if no QLineEdit is created centralWidget->layout()->addWidget(new QLineEdit()); wnd.setCentralWidget(centralWidget); wnd.show(); return app.exec(); }
Without `Qt::AA_Use96Dpi` set, no problem.
When Qt::AA_Use96Dpi is set:
- Without QLineEdit() being created, menu font is big
- With QLineEdit() being created, menu font is small
In addition to a potential bugfix, I would appreciate to:
- Have an explanation why creating a QLineEdit impacts the whole app menu rendering!
- A potential workaround