qt5base-lts/examples/widgets/graphicsview/chip
Tang Haixiang 7a7023b7b1 Chip example: fix an accidental bool->int conversion when using PMF connections
The example was refactored to use the PMF connection syntax.
However this introduced a problem: when connecting a QAbstractButton
to a slot that has a default parameter, the semantics of the connection
change between string-based connections and PMF.

Specifically: when connecting the

  QAbstractButton::clicked(bool checked = false)

signal to a slot like

  View::zoomIn(int level = 1)

then a string-based connection like

  connect(button, SIGNAL(clicked()), this, SLOT(zoomIn()))

would call zoomIn without carrying the signal's parameter over.
In other words, zoomIn's parameter is defaulted. The same connection
using PFM instead is

  connect(button, &QAbstractButton::clicked,
          this, &View::zoomIn)

which would "connect" the arguments. This makes emissions that pass
false as clicked's parameter result in a zoomIn by 0.

Fix it by avoiding the default parameter of zoomIn -- just split
the function in two (zoomIn and zoomInBy).

Amends 8cf8122314.

Pick-to: 5.15 6.2 6.3
Fixes: QTBUG-100135
Done-with: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Change-Id: I10c150c648034449e3154140108de2d64326d965
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-04-13 11:36:34 +08:00
..
chip.cpp Widgets/GraphicsView examples: cleanup 2019-09-05 17:40:36 +02:00
chip.h Use QList instead of QVector in examples 2020-06-23 14:01:11 +02:00
chip.pro Remove deprecated QGL* classes 2019-12-11 11:53:15 +01:00
CMakeLists.txt Examples: Remove unneeded CMake options 2022-01-24 14:00:00 +01:00
fileprint.png Moving .qdoc files under examples/widgets/doc 2012-08-20 12:20:55 +02:00
images.qrc Moving .qdoc files under examples/widgets/doc 2012-08-20 12:20:55 +02:00
main.cpp Updated license headers 2016-01-21 18:55:32 +00:00
mainwindow.cpp Widgets/GraphicsView examples: cleanup 2019-09-05 17:40:36 +02:00
mainwindow.h Widgets/GraphicsView examples: cleanup 2019-09-05 17:40:36 +02:00
qt4logo.png Moving .qdoc files under examples/widgets/doc 2012-08-20 12:20:55 +02:00
rotateleft.png Moving .qdoc files under examples/widgets/doc 2012-08-20 12:20:55 +02:00
rotateright.png Moving .qdoc files under examples/widgets/doc 2012-08-20 12:20:55 +02:00
view.cpp Chip example: fix an accidental bool->int conversion when using PMF connections 2022-04-13 11:36:34 +08:00
view.h Chip example: fix an accidental bool->int conversion when using PMF connections 2022-04-13 11:36:34 +08:00
zoomin.png Moving .qdoc files under examples/widgets/doc 2012-08-20 12:20:55 +02:00
zoomout.png Moving .qdoc files under examples/widgets/doc 2012-08-20 12:20:55 +02:00