[Qt-interest] question about destroyed signal

suse opensuse.iwfer at gmail.com
Wed Dec 24 13:29:15 CET 2008


I want to show a message box when a dialog closed.I connect destroyed signal to a slot,but
it doesn't work.Could you help me?
as below:
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 myslot(QObject *);
private:
    Ui_MyWidget ui;
    QDialog *d; 
};
//mywidget.cpp
MyWidget::MyWidget(QWidget *parent)
    : QMainWindow(parent)
{
    ui.setupUi(this);
    d = new QDialog(this);
    d->show();
    QObject::connect(d,SIGNAL(destroyed(QObject *) ),this,SLOT(mySlot(QObject *) ));
}
void MyWidget::mySlot(QObject *)
{
QMessageBox::information(this,tr("tip"),tr("test"));
}

   d is a member fo MyWidget class. I want a message box after QDialog closed. 
Do I get something wrong? how do i correct it?

Thank you.

2008-12-24 



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


More information about the Qt-interest-old mailing list