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

Widgets Not Redrawing on MacOS

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P2: Important
    • None
    • 5.11.0
    • None
    • MacOS 10.13.3

      Qt 5.10.0

       
    • macOS

    Description

      I'm experiencing an issue with Qt 5.11.0 on on MacOS 10.13 where widgets are not redrawing after setText() is called.  This problem did not exist in Qt 5.10.0, so it seems to have been introduced in 5.11.0.  The problem occurs only on MacOS, and does not occur on Windows 8.1 or Linux Mint Cinnamon.

      Example Program To Illustrate Problem

      Here is a short program to demonstrate the issue:

      testdlg.h

      #ifndef TESTDLG_H
      #define TESTDLG_H
      
      #include <QtWidgets>
      
      class TestDlg : public QDialog
      {
          Q_OBJECT
      
      private:
          QLabel* label1;
          QLabel* label2;
          QPushButton* button;
      
      public:
          TestDlg()
          {
              label1 = new QLabel(tr("<h2>Process Running</h2>"));
              label2 = new QLabel(tr("Label that doesn't update"));
              button = new QPushButton(tr("Abort"));
              connect(button, SIGNAL(clicked()), this, SLOT(abort()));
      
              QVBoxLayout* layout = new QVBoxLayout;
              layout->addWidget(label1);
              layout->addWidget(label2);
              layout->addWidget(button);
              setLayout(layout);
          }
      
      private slots:
          void abort()
          {
              label1->setText(tr("<h2>Process Aborted</h2>"));
              label2->setText(tr("Label after abort"));
              button->setText(tr("Close"));
          }
      };
      
      #endif // TESTDLG_H
      

      main.cpp

      #include <QApplication>
      #include "testdlg.h"
      
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
      
          TestDlg dialog;
          dialog.show();
      
          return app.exec();
      }
      

      Clicking the "Abort" button causes the abort() function to be called, which changes the text on the two QLables and the QPushButton.  However, on MacOS only the label1 text changes, and the label2 text and button text remain unchanged.  This can be seen on the attached screenshot.

      If you cover the dialog box with another window, then uncover it, the window will redraw with both QLables and the QPushButton all updated to the text set in abort().  It therefore seems that the text is being set but the widgets are not being redrawn until a redraw is triggered by covering and uncovering the window.

      Running the same program on Windows or Linux with Qt 5.11.0 the problem does not occur and all three widgets update immediately upon pressing the "Abort" button.  Testing the program on MacOS with Qt 5.10.0 the three widgets again update immediately when the "Abort" button is pressed.   The issue is therefore exclusive to Qt 5.11.0 on MacOS.

      Other Redraw Issues

      At the bottom of the screenshot I have shown another redraw issue.  In that example I commented out the three lines involving label1, ran the program and clicked the "Abort" button.  As you can see, label2 has updated but parts of the original text still remain.  It therefore appears that there are other general redraw issues in Qt 5.11.0 on MacOS that weren't present in Qt 5.10.0.

      Attachments

        1. MacOSRedrawBug.png
          52 kB
          Richard Craig

        Issue Links

          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
              inviska Richard Craig
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes