Important: Please read the Qt Code of Conduct -

Effects of Qt 4 QMenuBar::clear()

  • When I read the documentation for Qt 4.8's void QMenuBar::clear() method, and it says, "Removes all the actions from the menu bar." I interpret that to mean that if I call this on a QMenuBar instance I have created, it deletes--using delete--all the QMenu objects, and any QActions I may have added (using new, of course, in doing so) .

    Reasonable interpretation?

  • Lifetime Qt Champion


    The best way to ensure that is to go through the code. It's Qt 5 but the code for that class didn't moved much.

  • I would argue that remove and delete are two different things. I think it would depend upon how the actions were created. Do you still have pointer references to the actions after clear(), or were they created by something like the following pseudo-code?

    addAction(new Action("something"))

Log in to reply