destructors in Qt4

后端 未结 5 1106
小鲜肉
小鲜肉 2020-12-31 11:17

I\'m very confused about using destructors in Qt4 and hope, you guys can help me.
When I have a method like this (with \"Des\" is a class):

void Widget::         


        
5条回答
  •  旧时难觅i
    2020-12-31 12:11

    Richardwb's answer is a good one - but the other approach is to use the deleteLater slot, like so:

    Des *test = new Des;
    test->show();
    connect(test, SIGNAL(closed()), test, SLOT(deleteLater()));
    

    Obviously the closed() signal can be replaced with whatever signal you want.

提交回复
热议问题