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

Suggestion for QWidget::restoreGeometry() on MDI Windows

XMLWordPrintable

      QWidget::saveGeometry() and QWidget::restoreGeometry() does not work well for QMdi Windows.

      This is because restoreGeometry() uses the desktop's geometry to constraint the widgets position and
      size. It would be better, to use the parent's (QWorkspace) geometry
      if the window is a QWorkspaceChild. The desktop's geometry could be
      used, if it is a toplevel widget.

      The documentation says saveGeometry() and restoreGeometry()
      are only to be used for toplevel widgets. So it is documented behaviour.

      But the attached little patch for qwidget.cpp would give this
      feature.

      --- qwidget.orig.cpp Mon Oct 01 13:59:42 2007
      +++ qwidget.cpp Wed Feb 06 18:54:12 2008
      @@ -5065,7 +5065,11 @@
           if (restoredScreenNumber >= desktop->numScreens())
               restoredScreenNumber = desktop->primaryScreen();
       
      -    const QRect availableGeometry = desktop->availableGeometry(restoredScreenNumber);
      +    QRect availableGeometry;
      +    if (parentWidget())
      +        availableGeometry = parentWidget()->geometry();
      +    else
      +  availableGeometry = desktop->availableGeometry(restoredScreenNumber);
       
           // Modify the restored geometry if we are about to restore to coordinates
           // that would make the window "lost". This happens if:
      

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

            Unassigned Unassigned
            admin Administrator
            Votes:
            7 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes