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

Hiding and showing a QMainWindow results in resize

    XMLWordPrintable

Details

    Description

      The steps to reproduce this are:

      QMainWindow::hide();
      use mouse to resize the window
      QMainWindow::show();

      this will cause the window to shirnk, because adjustSize() is called in QWidget::setVisible() if Qt::WA_Resized is false.

      The following code reproduces this behaviour:

      Use QWidget instead of QMainWindow or uncomment the setAttribute() to stop the shrining.

      #include <QtGui>
      #include <QDebug>

      class MainWidget : public QWidget
      {
      Q_OBJECT

      public slots:
      void showHide()
      {
      if (showHideWidget->isVisible())
      showHideWidget->hide();
      else

      { qDebug() << showHideWidget->testAttribute(Qt::WA_Resized); // showHideWidget->setAttribute(Qt::WA_Resized); showHideWidget->show(); }

      }

      public:
      MainWidget(QWidget *parent = 0) : QWidget(parent)

      { showHideButton = new QPushButton("Show-Hide"); showHideWidget = new QMainWindow; QHBoxLayout *layout = new QHBoxLayout; layout->addWidget(showHideButton); setLayout(layout); connect(showHideButton, SIGNAL(clicked()), this, SLOT(showHide())); }

      private:
      QPushButton *showHideButton;
      QWidget *showHideWidget;
      };

      #include "main.moc"

      int main(int argc, char **argv)
      {
      QApplication app(argc, argv);
      MainWidget *main = new MainWidget;
      main->show();
      return app.exec();
      }

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            mpejcoch Martin Pejcoch (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes