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

[REG] QWidget::showNormal() does not restore to the correct location when window zoomed by user

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 4.6.0, 4.7.1
    • 4.5.2
    • Widgets: Main Window
    • None
    • 4567799c51b4126c693746e7c5c963faddb40225

    Description

      There is an issue on the Mac (Carbon), that seems to have been introduced in the latest Qt build (4.5.2) 4.5.0 does not show this behavior. If a showNormal() is called on a maximized widget, which has a minimum size, the widget moves off the screen on the Mac. As the title bar is offscreen, it cannot be moved back onto the screen.

      To reproduce, launch the demo app on the Mac, maximize the window and hit the big button ("Maximize Window and Press Me!") in the window.

      Also if the minimum size is not set, another bug occurs: After the window is brought back to its normal state, it is completely white. To see this, comment out "setMinimum" lines in sample

      #include <QtGui>
      
      class CMaximizeHandler : public QObject
      {
          Q_OBJECT
              public:
          CMaximizeHandler (QWidget* wdt) : QObject (wdt) { }
      
      public slots:
          void onButtonPressed()
          {
              // Un-maximize window again...
              QWidget* wdgt = qobject_cast<QWidget*> (parent ());
              wdgt->showNormal ();
          }
      
          void onButton2Pressed()
          {
              // Maximize window, this will set previous size correctly...
              QWidget* wdgt = qobject_cast<QWidget*> (parent ());
              wdgt->showMaximized();
          }
      
      };
      
      //This moc include is to get everything in a single file - for quick testing only
      #include "main.moc"
      
      int main(int argc, char **argv)
      {
          QApplication app(argc, argv);
      
          //QFrame* frm = new QFrame();
          QDialog* frm = new QDialog();
          QVBoxLayout *layout = new QVBoxLayout;
      
          // The "magic ingredient" to produce the bug: Set a minimum size!
          frm->setMinimumWidth(320);
          frm->setMinimumHeight(240);
          //
          QPushButton* btn = new QPushButton (frm);
          QPushButton* btn2 = new QPushButton (frm);
      
          layout->addWidget(btn);
          layout->addWidget(btn2);
      
      
          btn->resize (640, 480);
          btn->setText ("Maximize Window and Press Me!");
          btn2->setText ("Press Me to Zoom!");
          frm->setLayout(layout);
          frm->show ();
      
          CMaximizeHandler* handler = new CMaximizeHandler (frm);
      
          QObject::connect (btn, SIGNAL (clicked()), handler, SLOT (onButtonPressed ()));
          QObject::connect (btn2, SIGNAL (clicked()), handler, SLOT (onButton2Pressed ()));
      
          return app.exec();
      }
      

      Attachments

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

        Activity

          People

            dzyubenk Denis Dzyubenko (Inactive)
            dettman Dean Dettman (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes