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

X11: QMdiArea::subWindowActivated(0) is called when pressing cancel in dialog

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P3: Somewhat important
    • Some future release
    • 4.4.0
    • GUI: Workspace
    • None

    Description

      The documentation of void QMdiArea::subWindowActivated ( QMdiSubWindow * window ) [signal] says,
      "
      QMdiArea emits this signal after window has been activated. When window is 0, QMdiArea has just deactivated its last active window, and there are no active windows on the workspace.
      "

      The documentation could be understood so that when the signal is emitted
      with zero, there could still be windows residing in the QMdiArea, but
      none of them would be active windows.

      This is not obvious from the current documentation. If this is the case the documentation should be cleared up and explain better in which cases QMdiArea::subWindowActivated ( QMdiSubWindow * window ) with window zero is emitted.

      Reproducible with the following example:

      • Pressing the QPushButton to create dialog, and then pressing "cancel" in the file dialog, the signal QMdiArea::subWindowActivated(0) is sent on Linux.
      • On Mac subWindowActivated() is not called with 0 when doing this.

      #include <QtGui>
      #include <QDebug>

      class CustomWidget : public QPushButton
      { Q_OBJECT
      public:
      CustomWidget(QWidget* parent=0) : QPushButton(parent)

      { connect(this,SIGNAL(clicked()), this, SLOT(add())); }

      QMdiArea *area;

      public slots:
      void aSlot(QMdiSubWindow * w)

      { qDebug() << "aSlot invoked" << w; }

      void add()

      { QFileDialog::getOpenFileName(); QWidget *w1 = new QWidget; QMdiSubWindow *subWindow1 = new QMdiSubWindow; subWindow1->setWidget(w1); subWindow1->setAttribute(Qt::WA_DeleteOnClose); area->addSubWindow(subWindow1); subWindow1->show(); qDebug() << "add invoked"; }

      protected:
      void paintEvent(QPaintEvent *pe)

      { QPushButton::paintEvent(pe); }

      };

      #include "main.moc"

      int main(int argc, char *argv[])
      {
      QApplication app(argc, argv);

      QMdiArea area(0);
      CustomWidget wid;
      wid.area = &area;
      wid.show();
      QObject::connect(&area, SIGNAL(subWindowActivated ( QMdiSubWindow * ) ), &wid, SLOT(aSlot(QMdiSubWindow *)));

      QWidget *w1 = new QWidget;
      QWidget *w2 = new QWidget;

      area.show();

      QMdiSubWindow *subWindow1 = new QMdiSubWindow;
      subWindow1->setWidget(w1);
      subWindow1->setAttribute(Qt::WA_DeleteOnClose);

      area.addSubWindow(subWindow1);

      subWindow1->show();

      // area.addSubWindow(&w2);

      return app.exec();
      }

      Attachments

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

        Activity

          People

            bjnilsen Bjørn Erik Nilsen
            admin Administrator
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes