[Qt-interest] question about destroyed signal

Anthony Serdyukov uksus70 at gmail.com
Wed Dec 24 13:50:20 CET 2008


Closing dialog does not cause its deletion in your case.

Use other QDialog's signals.

2008/12/24 suse <opensuse.iwfer at gmail.com>:
> 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
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>



-- 
Regards,
Anthony



More information about the Qt-interest-old mailing list