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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Need More Info
    • Priority: P3: Somewhat important
    • Resolution: Incomplete
    • Affects Version/s: 5.3.2, 5.4.0
    • Fix Version/s: None
    • Component/s: GUI: Window management
    • Labels:
    • Environment:
      OS X 10.9.4
    • Platform/s:
      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

            • Assignee:
              srutledg Shawn Rutledge
              Reporter:
              mnaydenov Mihail Naydenov
            • Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Gerrit Reviews

                There are no open Gerrit changes