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

OS X: QWindow's QScreen reports wrong rect on multi monitor setup

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.3.2, 5.4.0
    • GUI: Window management
    • OS X 10.9.4
    • macOS

    Description

      On multi monitor setup

      widget->windowHandle()->screen()->geometry()
      

      will always initially report the rect of the main screen (screen 0) even if the window is shown on a different screen.

      Only after the window is moved to the main screen and back to the second it will start reporting correct dimensions.

      Reproduce:

      • Connect a second monitor (to your Mac)
      • Move QCreator to the second monitor
      • Compile and run the code below
      #include <QWidget>
      #include <QApplication>
      #include <QDebug>
      #include <QWindow>
      #include <QScreen>
      #include <QDesktopWidget>
      #include <QKeyEvent>
      
      class Widget : public QWidget
      {
        using Base = QWidget;
      
      protected:
      
        void keyPressEvent(QKeyEvent* e)
        {
          if(e->key() == Qt::Key_Space)
          {
            qDebug()<<windowHandle()->screen()->geometry()<<QApplication::desktop()->screenGeometry(this);
          }
        }
      
      
      };
      
      
      int main(int argc, char *argv[])
      {
        QApplication a(argc, argv);
        Widget w;
      
        w.show();
      
        return a.exec();
      }
      
      
      • Press space, the rect of the main monitor is printed first, then the correct rect from QDesktopWidget

      Attachments

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

        Activity

          People

            srutledg Shawn Rutledge
            mnaydenov Mihail Naydenov
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes