Important: Please read the Qt Code of Conduct -

Does QStatusBar takes ownership of widget?

  • I was reading the docs and it don't say if QStatusBar takes ownership of a widget when using addWidget or addPermanentWidget.

  • Qt Champions 2017

    It becomes childWidget. It will be deleted if status bar is deleted. What you wanted to achieve ? Can add more details ? Where is confusion coming ?

  • I just wanted to know if it takes ownership or the parenting, usually the documentation points out when the method does or does not take ownership.

    Take as an example QLabel::setMovie, it does not take the ownership of the QMovie and in the docs it says that.

    I read the source code and noticed that addWidget is using insertWidget internally and insertWidget reparenting the widget.

    It's solved, thank you.

  • Lifetime Qt Champion

    In most cases the docs mention if ownership is not transferred if there can be any doubts.
    In most cases where you give widget classX to to other widget based class as pointer, the normal
    object tree is in effect.
    And parent/container owns the inserted widget.

Log in to reply