[Qt-interest] question about destroyed signal
Anthony Serdyukov
uksus70 at gmail.com
Thu Dec 25 05:30:01 CET 2008
You have mismatch of a slot name: on_button_clicked and
on_buttonA_clicked. Hope it's just a misprint.
Are you shure the on_button_clicked slot is called?
Furthermore, I'd suggest you to use d->deleteLater() instead of pure
delete operator. However, delete operator should cause emitting this
signal, too.
Cite from documentation:
void QObject::destroyed ( QObject * obj = 0 ) [signal]
This signal is emitted immediately before the object obj is destroyed,
and can not be blocked.
2008/12/25 suse <opensuse.iwfer at gmail.com>:
> 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
> ________________________________
> _______________________________________________
> 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