Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-84697

Support reference counting for QObject in Qt6

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Won't Do
    • Not Evaluated
    • None
    • 6.0
    • Core: Object Model
    • None
    • All

    Description

      In Qt5, QObject s are owned and parented by the parent QObject.

      Ownership means the lifetime of a QObject is explicitly decided by the parent (usually deleted at dtor of the parent). Parenthood means the functionality is managed or affected by the parent, such as event propagation, or ancestor search (e.g. QWidget::window()), or UI layout, etc.

      I suggest we add support for shared ownership of QObject, e.g. by std::shared_ptr. Thus one QObject can be owned by multiple entities, and is automaticly deleted when the last ownership is released. This would enable some much more flexible software structure. However the parenthood would remain the same as before. Each QObject would still have 0 or 1 parent.

      I believe this kind of change breaks the binary compatibility. So it is a good opportunity to do it in Qt 6.0.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            zwhfly WH Z
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes