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

Setting flags on QMdiSubWindow in the QMdiArea doesn't work correctly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P4: Low
    • 5.3.0
    • 4.6.2
    • GUI: Workspace
    • None
    • 5e99b07a072bedee239ed6980a44719da9ffa7c9

    Description

      When window flags are set for the QMdiSubWindow, after this window has been created, the change doesn't happen correctly. A workaround for this problem is to set a parent for the sub window, since this will cause the internal private function to be called and the properties to be updated correctly.


      Example with an implemented workaround
      #include <QtGui>
      
      class ControlWidget : public QMdiArea
      {
          Q_OBJECT
      
      public:
          ControlWidget(QWidget *parent = 0) : QMdiArea(parent)
          {
              QPushButton *pb = new QPushButton("Swap flags");
              addSubWindow(pb);
              swFrameless = addSubWindow(new QTextEdit, Qt::FramelessWindowHint);
              swWithFrame = addSubWindow(new QTextEdit);
      
              originalWindowFlags = swWithFrame->windowFlags();
      
              swap = true;
      
              connect(pb, SIGNAL(clicked()), this, SLOT(swapFlags()));
          }
      
      public slots:
          void swapFlags()
          {
              if (swap)
              {
                  QRect geo1 = swWithFrame->geometry();
                  swWithFrame->setWindowFlags(Qt::FramelessWindowHint);
                  swWithFrame->setParent(0);
                  addSubWindow(swWithFrame);
                  swWithFrame->setGeometry(geo1);
      
                  QRect geo2 = swFrameless->geometry();
                  swFrameless->setWindowFlags(originalWindowFlags);
                  swFrameless->setParent(0);
                  addSubWindow(swFrameless);
                  swFrameless->setGeometry(geo2);
              }
              else
              {
                  QRect geo1 = swWithFrame->geometry();
                  swWithFrame->setWindowFlags(originalWindowFlags);
                  swWithFrame->setParent(0);
                  addSubWindow(swWithFrame);
                  swWithFrame->setGeometry(geo1);
      
                  QRect geo2 = swFrameless->geometry();
                  swFrameless->setWindowFlags(Qt::FramelessWindowHint);
                  swFrameless->setParent(0);
                  addSubWindow(swFrameless);
                  swFrameless->setGeometry(geo2);
              }
      
              swWithFrame->show();
              swFrameless->show();
      
              swap = !swap;
          }
      
      private:
          QMdiSubWindow *swFrameless;
          QMdiSubWindow *swWithFrame;
          Qt::WindowFlags originalWindowFlags;
          bool swap;
      };
      
      #include "main.moc"
      
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
      
          ControlWidget area;
          area.show();
      
          return app.exec();
      }
      

      Attachments

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

        Activity

          People

            veelo Bastiaan Veelo
            mpejcoch Martin Pejcoch (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes