Details
-
Bug
-
Resolution: Out of scope
-
P3: Somewhat important
-
4.4.0
-
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)
QMdiArea *area;
public slots:
void aSlot(QMdiSubWindow * 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)
};
#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();
}