destructors in Qt4

后端 未结 5 1107
小鲜肉
小鲜肉 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条回答
  •  旧巷少年郎
    2020-12-31 12:13

    In most cases you should create widgets on the stack:

        QPushButton push("neu");
    

    This way, they get deleted when they become out of scope. If you really want to create them on the heap, then it's your responsibility to call delete on them when they are not needed anymore.

提交回复
热议问题