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

Using any application's stylesheet breaks native QMessageBox

    XMLWordPrintable

Details

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

    Description

      Under Android, using QMessageBox shows native popup's. However, when setting any stylesheet to QApplication, this is broken, the message box show but does not look right: it's background is mixed with parent's background and it is not responsive and cannot be closed. See attached screenshots.

      Code to reproduce:

      main.cpp

       

      #include <QApplication>
      #include "mainwindow.h"
      int main( int argc, char* argv[] )
      {
          QApplication app(argc, argv);
          app.setStyleSheet("QLineEdit { background-color: yellow }");
          MainWindow wnd; 
          wnd.show();
          return app.exec();
      }
      

      mainframe.h

       

      #pragma once
      #include <QMainWindow>
      class MainWindow : public QMainWindow
      {
          Q_OBJECT
      public:
          MainWindow(QWidget* parent = NULL);
      public slots:
          void showMessageBox();
      };
      

      mainframe.cpp

       

      #include "mainwindow.h"
      #include <QDialog>
      #include <QPushButton>
      #include <QMessageBox>
      
      MainWindow::MainWindow( QWidget* parent ) : QMainWindow(parent)
      {
          QPushButton* centralWidget = new QPushButton("Open dialog",this);
          setCentralWidget(centralWidget);
          connect( centralWidget, &QPushButton::clicked, this, &MainWindow::showMessageBox);
      }
      void MainWindow::showMessageBox()
      {
          QMessageBox::information(this, "MessageBox", "Hello world", QMessageBox::Ok);
      }
      

       

      Attachments

        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:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes