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

Window y position wrong after app restart with saved positon settings

    XMLWordPrintable

Details

    Description

      If a native MenuBar from qt.labs.platform is used, the y position of the ApplicationWindow is applied incorrectly after a restart if it has been saved via Qt.labs.settings. Appearently the height of the MenuBar is not considered as part of the ApplicationWindow, thus the window is a bit closer to the bottom edge of the screen.

      Example

      main.qml:

       

      import QtQuick 2.11
      import QtQuick.Controls 2.4
      import Qt.labs.settings 1.0
      import Qt.labs.platform 1.0 as Platform
      
      
      ApplicationWindow {
          id: window
      
          visible: true
          width: 640
          height: 480
          title: qsTr("Example")
      
          Settings {
              id: appSettings
      
              property alias x: window.x
              property alias y: window.y
              property alias width: window.width
              property alias height: window.height
          }
      
          Platform.MenuBar {
      
              Platform.Menu {
                  id: settingsToolButton
                  title: "File"
      
                  Platform.MenuItem {
                      id: settingsMenuItem
                      text: "New..."
                  }
              }
          }
      }
      

       

      main.cpp

       

      #include <QGuiApplication>
      #include <QQmlApplicationEngine>
      
      
      int main(int argc, char *argv[])
      {
          QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
      
          QGuiApplication app(argc, argv);
      
          app.setOrganizationName("random.company");
          app.setOrganizationDomain("random-company.com");
          app.setApplicationName("Test PRG1");
      
          QQmlApplicationEngine engine;
          engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
          if (engine.rootObjects().isEmpty())
              return -1;
      
          return app.exec();
      }
      

       

       

      Attachments

        1. test_ypos_restart.7z
          1 kB
          Daniel Rauch
        2. window_ypos_restart.gif
          332 kB
          Daniel Rauch
        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
            danra Daniel Rauch
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes