[Qt-interest] question about destroyed signal

suse opensuse.iwfer at gmail.com
Thu Dec 25 05:05:17 CET 2008


In which case signal destroyed will be emitted?  
Which I cared about is the SIGNAL destroyed(QObject *),I don't know when it will be emitted.

in this test program, "close" a QDialog or a QWidget equals to hide it, dialog will not be destroyed.It's clarify.

And then, I changed the test program;
click button will cause delete the dialog;but destroyed() still is not emitted.
help me~
Thanks!

as below:
//main.cpp
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    MyWidget widget;
    widget.show();
    return app.exec();
}
//MyWidget.h
class MyWidget : public QMainWindow
{
    Q_OBJECT
public:
    MyWidget(QWidget *parent = 0);
private slots:
    void on_button_clicked();
    void mySlot(QObject *);
private:
    Ui_MyWidget ui;
    QWidget *d;
};
//MyWidget.cpp
MyWidget::MyWidget(QWidget *parent)
    : QMainWindow(parent)
{
    ui.setupUi(this);
    d = new QWidget(0);
    d->show();
    QObject::connect(d,SIGNAL(destroyed(QObject *)),this,SLOT(mySlot()));
}

void MyWidget::on_buttonA_clicked() //
{
delete d;
d = NULL;
}

void MyWidget::mySlot(QObject *)
{
QMessageBox::information(this,tr("提示"),tr("aaaa"));
}



2008-12-25 



suse 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20081225/e39632e0/attachment.html 


More information about the Qt-interest-old mailing list