qt5base-lts/examples
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
..
aggregate install a sane top-level examples.pro file 2012-12-11 13:37:57 +01:00
corelib Move rsslisting example into corelibe/serialization 2023-03-21 14:49:09 +01:00
dbus dbus examples: Remove "Example" from example names 2023-03-24 19:29:11 +01:00
embedded examples: port embedded examples to new connection style 2022-12-21 21:52:17 +01:00
gui Remove "Analog Clock Window Example" 2023-02-07 17:34:42 +00:00
network Remove loopback network example 2023-03-23 16:02:28 +01:00
opengl Move hellogles3 docs to where the rest of these files live 2023-03-23 15:13:03 +01:00
qmake examples: port qmake examples to new connection style 2022-12-21 22:52:17 +02:00
qpa Examples: Add missing include guards 2023-02-01 18:12:36 +00:00
qtconcurrent Example: rename progressdialog to primecounter and modernize it 2023-03-21 11:19:42 +01:00
qtestlib Examples: Use PRIVATE CMake linkage 2022-11-30 14:48:50 +01:00
sql examples: Connect Quit action to QCoreApplication::quit, not QWidget::close 2023-02-20 15:18:18 +01:00
vulkan Remove hellovulkanwindow example 2023-03-22 23:17:55 +01:00
widgets Fix pointer mismatch after QList::move() in tooltip example 2023-03-28 08:59:53 +00:00
xml Move rsslisting example into corelibe/serialization 2023-03-21 14:49:09 +01:00
CMakeLists.txt Examples: Use Qt6:: to qualify Qt CMake packages 2022-11-17 19:59:11 +01:00
examples.pro Turn off the dbus examples for qmake-generated VS projects 2021-02-09 15:45:06 +01:00
README Remove more references to demos. 2011-07-08 15:36:26 +02:00

Qt is supplied with a number of example applications that have been
written to provide developers with examples of the Qt API in use,
highlight good programming practice, and showcase features found in each of
Qt's core technologies.


Documentation for examples can be found in the Examples section
of the Qt documentation.