[Qt-interest] QMdiSubWindow WA_DeleteOnClose problem

Malyushytsky, Alex alex at wai.com
Wed Jan 20 01:31:48 CET 2010


Your slot might never be called cause its owner ( instance of  QMdiArea) might be  already deleted.
Check under the debugger if TraceWindowArea instance is deleted  before  Window.

Regards,
     Alex




From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Vidit...
Sent: Tuesday, January 19, 2010 8:37 AM
To: qt-interest at trolltech.com
Subject: [Qt-interest] QMdiSubWindow WA_DeleteOnClose problem

Hello

I have just started learning QT and I'm doing pretty well. But I'm stuck on this problem for weeks now. If someone could help me, I appreciate.

I create a QMdiSubwindow and set its attribute to DeleteOnClose.
The signal destroyed(QObject*) is connected to a custom slot.

The problem is when I call delete QMdiSubWindow explicitly (in the code), the slot is called, but if I close the window using GUI, the subwindow gets deleted but the slot is never called.

Here is the simplified code:


class TraceWindowArea : public QMdiArea
{
    Q_OBJECT
public:
    TraceWindowArea(QWidget *parent);

public slots:
    void openNewWindow(const HostStruct *);

private slots:
    void TraceWindowClosing(QObject*);

    //some other stuff too...
};

void TraceWindowArea::openNewWindow()
{
        Window = new QMdiSubWindow(this);

        Window->setAttribute(Qt::WA_DeleteOnClose);

        QTextEdit *TextBrowser = new QTextEdit(Window);
        Window->setWidget(TextBrowser);

        Window->show();

        connect(Window, SIGNAL(destroyed(QObject*)), this, SLOT(TraceWindowClosing(QObject*)));
}

void TraceWindowArea::TraceWindowClosing(QObject* ClosingWindow)
{
    //just for testing purpose
    QWidget * a = new QWidget(0);
    a->show();
}


Thanks
Vidit


---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.

"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."

"Please consider our environment before printing this email."




More information about the Qt-interest-old mailing list