qt5base-lts/examples/widgets/doc
Axel Spoerl 585bfe600a Fix pointer mismatch after QList::move() in tooltip example
The tooltip example moves shape items within a QWidget. Shape items are
stored in a QList of objects. When an item is moved, its pointer is
taken from the QList and stored in a member variable. To have the moved
item on the bottom of the list, QList::move() is called. This
operation re-arranges the list objects, and the member variable starts
pointing at a wrong object.

This patch changes the list from a list of objects, to a list of
pointers. Shape items are therefore allocated on the heap.
A destructor is added to free the heap with qDeleteAll.

The example's documentation is adapted accordingly and a snippet for
the destructor is added.

As a drive-by, int is replaced by qsizetype where it was used as an
index of a QList.

Fixes: QTBUG-104781
Pick-to: 6.5 6.2
Change-Id: I9be26fa7954be5f85729d24f166d66980af71801
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2023-03-28 08:59:53 +00:00
..
images Move anchor layout example to manual tests 2023-03-02 17:24:53 +00:00
src Fix pointer mismatch after QList::move() in tooltip example 2023-03-28 08:59:53 +00:00
dropsite.qdoc Brush up the drop site example 2022-09-21 20:52:14 +02:00