summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/widgets/animation/easing/window.cpp2
-rw-r--r--examples/widgets/widgets/icons/mainwindow.cpp11
-rw-r--r--examples/widgets/widgets/icons/mainwindow.h3
-rw-r--r--src/widgets/widgets/qabstractbutton.cpp48
-rw-r--r--src/widgets/widgets/qbuttongroup.cpp43
-rw-r--r--src/widgets/widgets/qbuttongroup.h10
-rw-r--r--tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp37
7 files changed, 22 insertions, 132 deletions
diff --git a/examples/widgets/animation/easing/window.cpp b/examples/widgets/animation/easing/window.cpp
index 378af07535..51d252e52b 100644
--- a/examples/widgets/animation/easing/window.cpp
+++ b/examples/widgets/animation/easing/window.cpp
@@ -67,7 +67,7 @@ Window::Window(QWidget *parent)
connect(m_ui.easingCurvePicker, &QListWidget::currentRowChanged,
this, &Window::curveChanged);
- connect(m_ui.buttonGroup, QOverload<QAbstractButton *>::of(&QButtonGroup::buttonClicked),
+ connect(m_ui.buttonGroup, &QButtonGroup::buttonClicked,
this, &Window::pathChanged);
connect(m_ui.periodSpinBox, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, &Window::periodChanged);
diff --git a/examples/widgets/widgets/icons/mainwindow.cpp b/examples/widgets/widgets/icons/mainwindow.cpp
index 4f990f7320..928470b054 100644
--- a/examples/widgets/widgets/icons/mainwindow.cpp
+++ b/examples/widgets/widgets/icons/mainwindow.cpp
@@ -172,15 +172,16 @@ void MainWindow::changeStyle(bool checked)
//! [4]
//! [5]
-void MainWindow::changeSize(int id, bool checked)
+void MainWindow::changeSize(QAbstractButton *button, bool checked)
{
if (!checked)
return;
- const bool other = id == int(OtherSize);
+ const int index = sizeButtonGroup->id(button);
+ const bool other = index == int(OtherSize);
const int extent = other
? otherSpinBox->value()
- : QApplication::style()->pixelMetric(static_cast<QStyle::PixelMetric>(id));
+ : QApplication::style()->pixelMetric(static_cast<QStyle::PixelMetric>(index));
previewArea->setSize(QSize(extent, extent));
otherSpinBox->setEnabled(other);
@@ -188,7 +189,7 @@ void MainWindow::changeSize(int id, bool checked)
void MainWindow::triggerChangeSize()
{
- changeSize(sizeButtonGroup->checkedId(), true);
+ changeSize(sizeButtonGroup->checkedButton(), true);
}
//! [5]
@@ -372,7 +373,7 @@ QWidget *MainWindow::createIconSizeGroupBox()
sizeButtonGroup = new QButtonGroup(this);
sizeButtonGroup->setExclusive(true);
- connect(sizeButtonGroup, QOverload<int, bool>::of(&QButtonGroup::buttonToggled),
+ connect(sizeButtonGroup, &QButtonGroup::buttonToggled,
this, &MainWindow::changeSize);
QRadioButton *smallRadioButton = new QRadioButton;
diff --git a/examples/widgets/widgets/icons/mainwindow.h b/examples/widgets/widgets/icons/mainwindow.h
index c67d828cab..9250711ecc 100644
--- a/examples/widgets/widgets/icons/mainwindow.h
+++ b/examples/widgets/widgets/icons/mainwindow.h
@@ -62,6 +62,7 @@ class QActionGroup;
class QLabel;
class QButtonGroup;
class QTableWidget;
+class QAbstractButton;
QT_END_NAMESPACE
class IconPreviewArea;
class IconSizeSpinBox;
@@ -81,7 +82,7 @@ public:
private slots:
void about();
void changeStyle(bool checked);
- void changeSize(int, bool);
+ void changeSize(QAbstractButton *button, bool);
void triggerChangeSize();
void changeIcon();
void addSampleImages();
diff --git a/src/widgets/widgets/qabstractbutton.cpp b/src/widgets/widgets/qabstractbutton.cpp
index 7c26b8cc42..77ffda10b0 100644
--- a/src/widgets/widgets/qabstractbutton.cpp
+++ b/src/widgets/widgets/qabstractbutton.cpp
@@ -413,16 +413,8 @@ void QAbstractButtonPrivate::emitClicked()
QPointer<QAbstractButton> guard(q);
emit q->clicked(checked);
#if QT_CONFIG(buttongroup)
- if (guard && group) {
-#if QT_DEPRECATED_SINCE(5, 15)
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_DEPRECATED
- emit group->buttonClicked(group->id(q));
- if (guard && group)
-QT_WARNING_POP
-#endif
- emit group->buttonClicked(q);
- }
+ if (guard && group)
+ emit group->buttonClicked(q);
#endif
}
@@ -432,16 +424,8 @@ void QAbstractButtonPrivate::emitPressed()
QPointer<QAbstractButton> guard(q);
emit q->pressed();
#if QT_CONFIG(buttongroup)
- if (guard && group) {
-#if QT_DEPRECATED_SINCE(5, 15)
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_DEPRECATED
- emit group->buttonPressed(group->id(q));
- if (guard && group)
-QT_WARNING_POP
-#endif
- emit group->buttonPressed(q);
- }
+ if (guard && group)
+ emit group->buttonPressed(q);
#endif
}
@@ -451,16 +435,8 @@ void QAbstractButtonPrivate::emitReleased()
QPointer<QAbstractButton> guard(q);
emit q->released();
#if QT_CONFIG(buttongroup)
- if (guard && group) {
-#if QT_DEPRECATED_SINCE(5, 15)
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_DEPRECATED
- emit group->buttonReleased(group->id(q));
- if (guard && group)
-QT_WARNING_POP
-#endif
- emit group->buttonReleased(q);
- }
+ if (guard && group)
+ emit group->buttonReleased(q);
#endif
}
@@ -470,16 +446,8 @@ void QAbstractButtonPrivate::emitToggled(bool checked)
QPointer<QAbstractButton> guard(q);
emit q->toggled(checked);
#if QT_CONFIG(buttongroup)
- if (guard && group) {
-#if QT_DEPRECATED_SINCE(5, 15)
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_DEPRECATED
- emit group->buttonToggled(group->id(q), checked);
- if (guard && group)
-QT_WARNING_POP
-#endif
- emit group->buttonToggled(q, checked);
- }
+ if (guard && group)
+ emit group->buttonToggled(q, checked);
#endif
}
diff --git a/src/widgets/widgets/qbuttongroup.cpp b/src/widgets/widgets/qbuttongroup.cpp
index 9162029cdb..1368c721ad 100644
--- a/src/widgets/widgets/qbuttongroup.cpp
+++ b/src/widgets/widgets/qbuttongroup.cpp
@@ -163,16 +163,6 @@ void QButtonGroup::setExclusive(bool exclusive)
*/
/*!
- \fn void QButtonGroup::buttonClicked(int id)
- \obsolete
-
- This signal is emitted when a button with the given \a id is
- clicked.
-
- \sa checkedButton(), QAbstractButton::clicked()
-*/
-
-/*!
\fn void QButtonGroup::buttonPressed(QAbstractButton *button)
\since 4.2
@@ -182,17 +172,6 @@ void QButtonGroup::setExclusive(bool exclusive)
*/
/*!
- \fn void QButtonGroup::buttonPressed(int id)
- \since 4.2
- \obsolete
-
- This signal is emitted when a button with the given \a id is
- pressed down.
-
- \sa QAbstractButton::pressed()
-*/
-
-/*!
\fn void QButtonGroup::buttonReleased(QAbstractButton *button)
\since 4.2
@@ -202,17 +181,6 @@ void QButtonGroup::setExclusive(bool exclusive)
*/
/*!
- \fn void QButtonGroup::buttonReleased(int id)
- \since 4.2
- \obsolete
-
- This signal is emitted when a button with the given \a id is
- released.
-
- \sa QAbstractButton::released()
-*/
-
-/*!
\fn void QButtonGroup::buttonToggled(QAbstractButton *button, bool checked)
\since 5.2
@@ -222,17 +190,6 @@ void QButtonGroup::setExclusive(bool exclusive)
\sa QAbstractButton::toggled()
*/
-/*!
- \fn void QButtonGroup::buttonToggled(int id, bool checked)
- \since 5.2
- \obsolete
-
- This signal is emitted when a button with the given \a id is toggled.
- \a checked is true if the button is checked, or false if the button is unchecked.
-
- \sa QAbstractButton::toggled()
-*/
-
/*!
Adds the given \a button to the button group. If \a id is -1,
diff --git a/src/widgets/widgets/qbuttongroup.h b/src/widgets/widgets/qbuttongroup.h
index 2989dcb4ba..838bf8abce 100644
--- a/src/widgets/widgets/qbuttongroup.h
+++ b/src/widgets/widgets/qbuttongroup.h
@@ -81,16 +81,6 @@ Q_SIGNALS:
void buttonPressed(QAbstractButton *);
void buttonReleased(QAbstractButton *);
void buttonToggled(QAbstractButton *, bool);
-#if QT_DEPRECATED_SINCE(5, 15)
- QT_DEPRECATED_VERSION_X_5_15("Use QButtonGroup::buttonClicked(QAbstractButton *) instead")
- void buttonClicked(int);
- QT_DEPRECATED_VERSION_X_5_15("Use QButtonGroup::buttonPressed(QAbstractButton *) instead")
- void buttonPressed(int);
- QT_DEPRECATED_VERSION_X_5_15("Use QButtonGroup::buttonReleased(QAbstractButton *) instead")
- void buttonReleased(int);
- QT_DEPRECATED_VERSION_X_5_15("Use QButtonGroup::buttonToggled(QAbstractButton *, bool) instead")
- void buttonToggled(int, bool);
-#endif
private:
Q_DISABLE_COPY(QButtonGroup)
diff --git a/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp b/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp
index 47dfc86a69..5d52acd1a2 100644
--- a/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp
+++ b/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp
@@ -280,67 +280,43 @@ void tst_QButtonGroup::testSignals()
qRegisterMetaType<QAbstractButton *>("QAbstractButton *");
QSignalSpy clickedSpy(&buttons, SIGNAL(buttonClicked(QAbstractButton*)));
- QSignalSpy clickedIdSpy(&buttons, SIGNAL(buttonClicked(int)));
QSignalSpy pressedSpy(&buttons, SIGNAL(buttonPressed(QAbstractButton*)));
- QSignalSpy pressedIdSpy(&buttons, SIGNAL(buttonPressed(int)));
QSignalSpy releasedSpy(&buttons, SIGNAL(buttonReleased(QAbstractButton*)));
- QSignalSpy releasedIdSpy(&buttons, SIGNAL(buttonReleased(int)));
pb1.animateClick();
QTestEventLoop::instance().enterLoop(1);
QCOMPARE(clickedSpy.count(), 1);
- QCOMPARE(clickedIdSpy.count(), 1);
- int expectedId = -2;
-
- QCOMPARE(clickedIdSpy.takeFirst().at(0).toInt(), expectedId);
QCOMPARE(pressedSpy.count(), 1);
- QCOMPARE(pressedIdSpy.count(), 1);
- QCOMPARE(pressedIdSpy.takeFirst().at(0).toInt(), expectedId);
QCOMPARE(releasedSpy.count(), 1);
- QCOMPARE(releasedIdSpy.count(), 1);
- QCOMPARE(releasedIdSpy.takeFirst().at(0).toInt(), expectedId);
clickedSpy.clear();
- clickedIdSpy.clear();
pressedSpy.clear();
- pressedIdSpy.clear();
releasedSpy.clear();
- releasedIdSpy.clear();
pb2.animateClick();
QTestEventLoop::instance().enterLoop(1);
QCOMPARE(clickedSpy.count(), 1);
- QCOMPARE(clickedIdSpy.count(), 1);
- QCOMPARE(clickedIdSpy.takeFirst().at(0).toInt(), 23);
QCOMPARE(pressedSpy.count(), 1);
- QCOMPARE(pressedIdSpy.count(), 1);
- QCOMPARE(pressedIdSpy.takeFirst().at(0).toInt(), 23);
QCOMPARE(releasedSpy.count(), 1);
- QCOMPARE(releasedIdSpy.count(), 1);
- QCOMPARE(releasedIdSpy.takeFirst().at(0).toInt(), 23);
QSignalSpy toggledSpy(&buttons, SIGNAL(buttonToggled(QAbstractButton*, bool)));
- QSignalSpy toggledIdSpy(&buttons, SIGNAL(buttonToggled(int, bool)));
pb1.setCheckable(true);
pb2.setCheckable(true);
pb1.toggle();
QCOMPARE(toggledSpy.count(), 1);
- QCOMPARE(toggledIdSpy.count(), 1);
pb2.toggle();
QCOMPARE(toggledSpy.count(), 3); // equals 3 since pb1 and pb2 are both toggled
- QCOMPARE(toggledIdSpy.count(), 3);
pb1.setCheckable(false);
pb2.setCheckable(false);
pb1.toggle();
QCOMPARE(toggledSpy.count(), 3);
- QCOMPARE(toggledIdSpy.count(), 3);
}
void tst_QButtonGroup::task106609()
@@ -372,7 +348,6 @@ void tst_QButtonGroup::task106609()
qRegisterMetaType<QAbstractButton*>("QAbstractButton*");
QSignalSpy spy1(buttons, SIGNAL(buttonClicked(QAbstractButton*)));
- QSignalSpy spy2(buttons, SIGNAL(buttonClicked(int)));
QApplication::setActiveWindow(&dlg);
QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&dlg));
@@ -381,8 +356,6 @@ void tst_QButtonGroup::task106609()
radio1->setChecked(true);
QTestEventLoop::instance().enterLoop(1);
- //qDebug() << "int:" << spy2.count() << "QAbstractButton*:" << spy1.count();
- QCOMPARE(spy2.count(), 2);
QCOMPARE(spy1.count(), 2);
}
@@ -427,11 +400,12 @@ public:
: group(group)
, deleteButton(deleteButton)
{
- connect(group, SIGNAL(buttonClicked(int)), SLOT(buttonClicked(int)));
+ connect(group, &QButtonGroup::buttonClicked,
+ this, &task209485_ButtonDeleter::buttonClicked);
}
private slots:
- void buttonClicked(int)
+ void buttonClicked()
{
if (deleteButton)
group->removeButton(group->buttons().first());
@@ -447,7 +421,7 @@ void tst_QButtonGroup::task209485_removeFromGroupInEventHandler_data()
QTest::addColumn<bool>("deleteButton");
QTest::addColumn<int>("signalCount");
QTest::newRow("buttonPress 1") << true << 1;
- QTest::newRow("buttonPress 2") << false << 2;
+ QTest::newRow("buttonPress 2") << false << 1;
}
void tst_QButtonGroup::task209485_removeFromGroupInEventHandler()
@@ -463,12 +437,11 @@ void tst_QButtonGroup::task209485_removeFromGroupInEventHandler()
task209485_ButtonDeleter buttonDeleter(&group, deleteButton);
QSignalSpy spy1(&group, SIGNAL(buttonClicked(QAbstractButton*)));
- QSignalSpy spy2(&group, SIGNAL(buttonClicked(int)));
// NOTE: Reintroducing the bug of this task will cause the following line to crash:
QTest::mouseClick(button, Qt::LeftButton);
- QCOMPARE(spy1.count() + spy2.count(), signalCount);
+ QCOMPARE(spy1.count(), signalCount);
}
void tst_QButtonGroup::autoIncrementId()