If you want to replace the old buttons with new ones, remember to delete any previous buttons you are not using anymore. Otherwise you will have memory leaks (the buttons will take memory that is allocated but can't be accesed and is useless). The best solution would be to try to reuse the buttons or keep a list of pointers to the buttons and use qDeleteAll(). But if all the buttons are children of your main widget and you don't use any other buttons in it, you may use this:
foreach
(QObject* child, children
()) { if(child->metaObject()->className() == "QPushButton")
child->deleteLater();
}
foreach(QObject* child, children()) {
if(child->metaObject()->className() == "QPushButton")
child->deleteLater();
}
To copy to clipboard, switch view to plain text mode
Bookmarks