summaryrefslogtreecommitdiffstats
path: root/examples/widgets/graphicsview
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2020-01-25 20:43:13 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2020-01-28 06:24:25 +0100
commitfb7c9dfc060a09b4b1fa6d474f106bb6c1d2d4df (patch)
treec083bd67b4a1a3abb6e90221cb8a69b4314c1c75 /examples/widgets/graphicsview
parent4bb897a3841f0f79150787e29fe122e1410bc119 (diff)
QButtonGroup: deprecate overloaded signals
Deprecate the overloaded signals buttonClicked/buttonPressed/buttonReleased/buttonToggled taking an int to avoid to need to use QOverload<> when connecting the signal. The id of a button in a button group can be easily fetched with QButtonGroup::id(). Task-number: QTBUG-80906 Change-Id: Idaaab54bbcb25cba543fc99f305b9f4743ee3ed8 Reviewed-by: Sze Howe Koh <szehowe.koh@gmail.com> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'examples/widgets/graphicsview')
-rw-r--r--examples/widgets/graphicsview/diagramscene/mainwindow.cpp13
-rw-r--r--examples/widgets/graphicsview/diagramscene/mainwindow.h4
2 files changed, 9 insertions, 8 deletions
diff --git a/examples/widgets/graphicsview/diagramscene/mainwindow.cpp b/examples/widgets/graphicsview/diagramscene/mainwindow.cpp
index 04ff42e3eb..58b959dd10 100644
--- a/examples/widgets/graphicsview/diagramscene/mainwindow.cpp
+++ b/examples/widgets/graphicsview/diagramscene/mainwindow.cpp
@@ -113,13 +113,14 @@ void MainWindow::backgroundButtonGroupClicked(QAbstractButton *button)
//! [1]
//! [2]
-void MainWindow::buttonGroupClicked(int id)
+void MainWindow::buttonGroupClicked(QAbstractButton *button)
{
const QList<QAbstractButton *> buttons = buttonGroup->buttons();
- for (QAbstractButton *button : buttons) {
- if (buttonGroup->button(id) != button)
+ for (QAbstractButton *myButton : buttons) {
+ if (myButton != button)
button->setChecked(false);
}
+ const int id = buttonGroup->id(button);
if (id == InsertTextButton) {
scene->setMode(DiagramScene::InsertText);
} else {
@@ -154,7 +155,7 @@ void MainWindow::deleteItem()
//! [3]
//! [4]
-void MainWindow::pointerGroupClicked(int)
+void MainWindow::pointerGroupClicked()
{
scene->setMode(DiagramScene::Mode(pointerTypeGroup->checkedId()));
}
@@ -334,7 +335,7 @@ void MainWindow::createToolBox()
{
buttonGroup = new QButtonGroup(this);
buttonGroup->setExclusive(false);
- connect(buttonGroup, QOverload<int>::of(&QButtonGroup::buttonClicked),
+ connect(buttonGroup, QOverload<QAbstractButton *>::of(&QButtonGroup::buttonClicked),
this, &MainWindow::buttonGroupClicked);
QGridLayout *layout = new QGridLayout;
layout->addWidget(createCellWidget(tr("Conditional"), DiagramItem::Conditional), 0, 0);
@@ -528,7 +529,7 @@ void MainWindow::createToolbars()
pointerTypeGroup = new QButtonGroup(this);
pointerTypeGroup->addButton(pointerButton, int(DiagramScene::MoveItem));
pointerTypeGroup->addButton(linePointerButton, int(DiagramScene::InsertLine));
- connect(pointerTypeGroup, QOverload<int>::of(&QButtonGroup::buttonClicked),
+ connect(pointerTypeGroup, QOverload<QAbstractButton *>::of(&QButtonGroup::buttonClicked),
this, &MainWindow::pointerGroupClicked);
sceneScaleCombo = new QComboBox;
diff --git a/examples/widgets/graphicsview/diagramscene/mainwindow.h b/examples/widgets/graphicsview/diagramscene/mainwindow.h
index e04224fbc7..9fcd1884ca 100644
--- a/examples/widgets/graphicsview/diagramscene/mainwindow.h
+++ b/examples/widgets/graphicsview/diagramscene/mainwindow.h
@@ -82,9 +82,9 @@ public:
private slots:
void backgroundButtonGroupClicked(QAbstractButton *button);
- void buttonGroupClicked(int id);
+ void buttonGroupClicked(QAbstractButton *button);
void deleteItem();
- void pointerGroupClicked(int id);
+ void pointerGroupClicked();
void bringToFront();
void sendToBack();
void itemInserted(DiagramItem *item);