summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkku Heikkila <markku.heikkila@digia.com>2011-11-11 14:35:23 +0100
committerFriedemann Kleint <Friedemann.Kleint@nokia.com>2011-11-11 14:35:23 +0100
commitdf819cfe17f6dfd089096063524932fc4975804f (patch)
tree99509989bc58170deda5694ce03fef58ce8f73f1
parentee3f763f3642d1a098e6293fbc586b34a3e6e8be (diff)
Fixed wrong QGroupBox check state
Handle mouserelease only if mouse is pressed in QGroupBox. Task-number: QTBUG-19170 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
-rw-r--r--src/gui/widgets/qgroupbox.cpp4
-rw-r--r--tests/auto/qgroupbox/tst_qgroupbox.cpp23
2 files changed, 27 insertions, 0 deletions
diff --git a/src/gui/widgets/qgroupbox.cpp b/src/gui/widgets/qgroupbox.cpp
index 56fb2dd412..db068cfad8 100644
--- a/src/gui/widgets/qgroupbox.cpp
+++ b/src/gui/widgets/qgroupbox.cpp
@@ -733,6 +733,10 @@ void QGroupBox::mouseReleaseEvent(QMouseEvent *event)
}
Q_D(QGroupBox);
+ if (!d->overCheckBox) {
+ event->ignore();
+ return;
+ }
QStyleOptionGroupBox box;
initStyleOption(&box);
QStyle::SubControl released = style()->hitTestComplexControl(QStyle::CC_GroupBox, &box,
diff --git a/tests/auto/qgroupbox/tst_qgroupbox.cpp b/tests/auto/qgroupbox/tst_qgroupbox.cpp
index f1388bc2b6..f3d26ef2f2 100644
--- a/tests/auto/qgroupbox/tst_qgroupbox.cpp
+++ b/tests/auto/qgroupbox/tst_qgroupbox.cpp
@@ -83,6 +83,7 @@ private slots:
void toggledVsClicked();
void childrenAreDisabled();
void propagateFocus();
+ void task_QTBUG_19170_ignoreMouseReleseEvent();
private:
bool checked;
@@ -473,5 +474,27 @@ void tst_QGroupBox::propagateFocus()
QTRY_COMPARE(qApp->focusWidget(), static_cast<QWidget*>(&lineEdit));
}
+void tst_QGroupBox::task_QTBUG_19170_ignoreMouseReleseEvent()
+{
+ QGroupBox box;
+ box.setCheckable(true);
+ box.setChecked(false);
+ box.setTitle("This is a test for QTBUG-19170");
+ box.show();
+
+ QStyleOptionGroupBox option;
+ option.initFrom(&box);
+ option.subControls = QStyle::SubControls(QStyle::SC_All);
+ QRect rect = box.style()->subControlRect(QStyle::CC_GroupBox, &option,
+ QStyle::SC_GroupBoxCheckBox, &box);
+
+ QTest::mouseClick(&box, Qt::LeftButton, 0, rect.center());
+ QCOMPARE(box.isChecked(), true);
+
+ box.setChecked(false);
+ QTest::mouseRelease(&box, Qt::LeftButton, 0, rect.center());
+ QCOMPARE(box.isChecked(), false);
+}
+
QTEST_MAIN(tst_QGroupBox)
#include "tst_qgroupbox.moc"