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

Android: Creating QLineEdit while Qt::AA_Use96Dpi is set makes menu font smaller

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.9.0
    • GUI: Menus
    • None
    • Android

    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

      Attachments

        1. with_QLineEdit.jpg
          39 kB
          Jean Porcherot
        2. without_QLineEdit.jpg
          35 kB
          Jean Porcherot
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            jpo38 Jean Porcherot
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes