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

setUnifiedTitleAndToolBarOnMac(true) and [save|restore]Geometry result in y slide of widget

    XMLWordPrintable

Details

    Description

      When setUnifiedTitleAndToolBarOnMac(true) and you have items in the
      toolbar, the Y position of the mainwindow will drop around 42 pixels
      each Quit/Run despite the fact that the window is not moved while the
      program is run.

      On quit the geometry is saved to QSettings. I have provided qdebug for
      the x & y on quit and run.

      For some reason related to setUnifiedTitleAndToolBarOnMac(true) Qt
      moves the Y down upon each Quit/run
      See enclosed sample file.

      Steps to recreate:

      Compile and run app.
      Notice where the mainwindow is on your screen.
      Quit app.
      Run app.
      Notice the main window has moved down approx. 42pixels since the last
      run even though you have not moved the window.
      Continue to quit/run until the window moves off the bottom of your
      screen.

      Now comment out this line:

      // setUnifiedTitleAndToolBarOnMac(true);

      and recompile and run again.

      Observe how the mainwindow no longer moves down after each Quit/Run.

      Example here :

      #include <QtGui>

      class MacMainWindow : public QMainWindow
      {
      Q_OBJECT
      public:
      MacMainWindow()

      { QSettings settings; restoreGeometry(settings.value("Geometry").toByteArray()); // qDebug() << x() << y(); toolBar = addToolBar(tr("Search")); toolBar->addAction("aaa"); toolBar->addAction("bbb"); setUnifiedTitleAndToolBarOnMac(true); }

      ~MacMainWindow()

      { QSettings settings; settings.setValue("Geometry", saveGeometry()); qDebug() << x() << y(); }

      void resizeEvent(QResizeEvent *e)

      { toolBar->updateGeometry(); }

      public:

      QToolBar * toolBar;
      };

      int main(int argc, char **argv)
      {
      QApplication app(argc, argv);
      MacMainWindow mainWindow;
      mainWindow.show();
      return app.exec();
      }

      #include "main.moc"

      Attachments

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

        Activity

          People

            sorvig Morten Sørvig
            dettman Dean Dettman (Inactive)
            Votes:
            23 Vote for this issue
            Watchers:
            21 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes