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

OSX Mavericks coordinate system with multiple monitors @ heterogeneous height is anchored to bottom instead of top

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Not Evaluated
    • None
    • 5.2.1
    • None
    • OSX 10.9.1
      Qt5.2.1
    • macOS

    Description

      When in the shorter of two monitors laid side by side, the vertical coordinate system seems to be counting from the top of the larger screen, with the smaller one positioned as linked to the bottom of the larger screen. This leads to widgets being shifted upwards from where they ought to be.

      Example, modified main.cpp from new QtCreator QtQuick Application based project:

      #include <QtGui/QGuiApplication>
      #include "qtquick2applicationviewer.h"
      #include <QScreen>
      #include <QDir>
      
      QString adjustPath(const QString &path)
      {
      #if defined(Q_OS_IOS)
          if (!QDir::isAbsolutePath(path))
              return QString::fromLatin1("%1/%2")
                      .arg(QCoreApplication::applicationDirPath(), path);
      #elif defined(Q_OS_MAC)
          if (!QDir::isAbsolutePath(path))
              return QString::fromLatin1("%1/../Resources/%2")
                      .arg(QCoreApplication::applicationDirPath(), path);
      #elif defined(Q_OS_BLACKBERRY)
          if (!QDir::isAbsolutePath(path))
              return QString::fromLatin1("app/native/%1").arg(path);
      #elif !defined(Q_OS_ANDROID)
          QString pathInInstallDir =
                  QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path);
          if (QFileInfo(pathInInstallDir).exists())
              return pathInInstallDir;
          pathInInstallDir =
                  QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path);
          if (QFileInfo(pathInInstallDir).exists())
              return pathInInstallDir;
      #elif defined(Q_OS_ANDROID_NO_SDK)
          return QLatin1String("/data/user/qt/") + path;
      #endif
          return path;
      }
      
      int main(int argc, char *argv[])
      {
          QGuiApplication app(argc, argv);
      
          /**
          QtQuick2ApplicationViewer viewer;
          viewer.setMainQmlFile(QStringLiteral("qml/Test/main.qml"));
          viewer.showExpanded();
          **/
      
          QQuickView* mainWindow = new QQuickView();
          mainWindow->setSource(QUrl(adjustPath("qml/Test/main.qml")));
          QRect a = mainWindow->screen()->availableGeometry();
          QRect r = mainWindow->frameGeometry();
          // r.moveCenter(a.center()); // this positions the window higher than center in the smaller screen
          r.moveCenter(a.center() - QPoint(0, mainWindow->screen()->availableGeometry().height() - mainWindow->screen()->virtualGeometry().height())); // this positions the window correctly in the center of the smaller screen
          mainWindow->setPosition(r.topLeft());
          mainWindow->show();
      
          return app.exec();
      }
      

      Attachments

        1. main.cpp
          2 kB
        2. main.cpp
          2 kB
        3. main.qml
          0.7 kB
        4. qtquick2applicationviewer.cpp
          3 kB
        5. qtquick2applicationviewer.h
          0.9 kB
        6. qtquick2applicationviewer.pri
          7 kB

        Issue Links

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

          Activity

            People

              sorvig Morten Sørvig
              sshen.vivox Scott Shen
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes