Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Does QStatusBar takes ownership of widget?
Qt 6.11 is out! See what's new in the release blog

Does QStatusBar takes ownership of widget?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 906 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mr Gisa
    wrote on last edited by
    #1

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

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Moderators Qt Champions 2024 Qt Champions 2022 Qt Champions 2017
      wrote on last edited by
      #2

      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 ?

      Dheerendra
      @Community Service
      Certified Qt Specialist
      https://www.pthinks.com

      1 Reply Last reply
      3
      • M Offline
        M Offline
        Mr Gisa
        wrote on last edited by
        #3

        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.

        mrjjM 1 Reply Last reply
        1
        • M Mr Gisa

          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.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by aha_1980
          #4

          @Mr-Gisa
          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.
          http://doc.qt.io/qt-5/objecttrees.html
          And parent/container owns the inserted widget.

          1 Reply Last reply
          3

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved