diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2019-10-07 16:09:37 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2019-10-11 13:53:49 +0200 |
commit | 1748dc3e2d2367f9f01666212a22e6b1dde5dc89 (patch) | |
tree | 6f206d7bd2142a5dc249e7d98611427ddaad8de1 /tests | |
parent | 81a790969395feff73fa600908822765e97424e5 (diff) |
QGroupBox: always disable children in a checkable, unchecked groupbox
The childEvent handler sets the enabled property of children as they are
added to the groupbox, but applications might later enable children and
check/uncheck the groupbox's checkbox in undefined order. In that case,
we would end up with enabled children inside a conceptually disabled
groupbox (the groupbox's checkbox represents the logical "disabled"
state), which breaks documented QWidget::enabled rules.
To make sure that all children are disabled as per the state of the
groupbox, we need to run that logic once the UI has been set up, and
before it becomes visible. This is what polishing is for, so listen
for that event in addition and handle it the same way as adding (which
duplicates things, but keeps existing code that might depend on things
being updated as they are added working).
Adds the case to the existing enabledChildPropagation test case.
[ChangeLog][QWidget][QGroupBox] Always disable children of a checkable,
unchecked group box before showing.
Change-Id: I978bd27b6f1a3f54ec745faeea529a98d0d93619
Fixes: QTBUG-25938
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp index 420ef56106..1b477fbbd0 100644 --- a/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp +++ b/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp @@ -295,6 +295,12 @@ void tst_QGroupBox::enabledChildPropagation() QVERIFY(!childWidget->isEnabled()); dialog = new QDialog(&testWidget); QVERIFY(dialog->isEnabled()); + + // children that are enabled after adding should still be disabled before + // they are shown + childWidget->setEnabled(true); + testWidget.show(); + QVERIFY(!childWidget->isEnabled()); } void tst_QGroupBox::sizeHint() |