简体   繁体   中英

Freeing Memory for QPushButtons with QMessageBox

I've instantiated a QMessageBox and added a couple of buttons to it like so:

QMessageBox message;
cancelButton = message.addButton(tr("Cancel"), QMessageBox::RejectRole);
okButton = message.addButton(tr("OK"), QMessageBox::ActionRole);

Is it necessary to call the destructors for each pushbutton before exiting, or does the QMessageBox destructor take care of everything?

No.

When parent objects are deleted they delete their children. So the buttons will be deleted when 'message' is.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM