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

[macOS] [Regression] QMenu not drawn properly when shown on regular display after shown on Retina display

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.12.5, 5.14.0 Alpha
    • 5.11.2, 5.12.2, 5.12.3
    • GUI: Menus
    • None
    • macOS 10.12, 10.13, Xcode 10.
    • macOS
    • fccb519809d8e64db0e9cc54852c8612fe59b6c7 (qt/qtbase/5.13)

    Description

      The attached code demonstrates a problem with displaying a QMenu. I am using an iMac with a retina display on the left and an external monitor (regular DPI) to the right of the iMac. If I run the attached application and click the button to display the menu when the window is on the Retina display, the menu displays correctly, even if I allow it to close and click the button again.

      If I move the window to the standard DPI display on the right and click the button, the menu pops up but all of the actions are invisible. If I hover over the actions, each action becomes visible as I hover over it.

      If I then close the menu and pop it up again while the window is on either display, I still get this broken behavior.

      I can reproduce this problem using the official build of 5.11.2 and 5.12.2, but not 5.9.6, on my machine running macOS 10.13. I'm building with Xcode 10.

       

      The code to reproduce this is simply:

      #include <QApplication>
      #include <QDialog>
      #include <QMenu>
      #include <QAction>
      #include <QToolButton>
      
      class TestDialog : public QDialog {
      	Q_OBJECT
      
      public:
      	TestDialog(QWidget* parent=nullptr) :
      	QDialog(parent),
      	  theButton(new QToolButton(this)),
      	  theMenu(new QMenu(this))
      	{
      		theButton->setText("Values");
      		theMenu->addAction("a");
      		theMenu->addAction("b");
      		theMenu->addAction("c");
      
      		// Make connection.
      		connect(theButton, &QAbstractButton::clicked, this, [=]() {
      			// Make sure that the button is drawn as being pressed (down).
      			theButton->setDown(true);
      
      			theMenu->exec(theButton->mapToGlobal(theButton->rect().bottomRight()));
      
      			// Make sure that the button is drawn as being released (up).
      			theButton->setDown(false);
      		});
      	}
      
      private:
      	QToolButton* theButton;
      	QMenu* theMenu;
      };
      
      
      int main(int argc, char *argv[])
      {
      	QApplication a(argc, argv);
      
      	TestDialog td;
      	td.show();
      
      	return a.exec();
      }
      
      
      #include "main.moc"
      

      Attachments

        1. FirstClickOnRetina.png
          FirstClickOnRetina.png
          21 kB
        2. ClickOnNonRetina.png
          ClickOnNonRetina.png
          6 kB
        3. ClickOnNonRetinaAndHover.png
          ClickOnNonRetinaAndHover.png
          6 kB
        4. QTBUG-74559.zip
          2 kB
        5. QtCreatorBlankMenu.png
          QtCreatorBlankMenu.png
          48 kB
        6. QMenu_rendering_broken.mp4
          491 kB

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              vestbo Tor Arne Vestbø
              aclight Adam Light
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes