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

QLayout::takeAt() example code does not delete item from layout

    XMLWordPrintable

Details

    • 322e5b7f5e35db73f7d7730a6fff558e153ad356 (qt/qtbase/5.15)

    Description

      I think there is a mistake in the section QLayoutItem * QLayout::takeAt(int index) [pure virtual] of the page QLayout Class Reference.

      The example read as follows:

      QLayoutItem *child;
      while ((child = layout->takeAt(0)) != 0)

      { ... delete child; }

      That code snippet doesn't actually delete the item from the layout.
      To delete the item from the layout you need to add delete child->widget().

      This is happening at least with QVBoxLayout.

      Attachments

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

        Activity

          People

            docteam Qt Documentation Team
            negralexx Alex
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes