QGroupBox: Exclude top level widgets from child event handling.
Prevent the QGroupBox from changing the enabled state of dialogs parented on it. Task-number: QTBUG-40132 Change-Id: I91cc6ccf5ade0b3a491020ed947d4aceca62d7b6 Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
This commit is contained in:
parent
08fd2a724d
commit
45854c75aa
@ -405,6 +405,8 @@ void QGroupBox::childEvent(QChildEvent *c)
|
|||||||
if (c->type() != QEvent::ChildAdded || !c->child()->isWidgetType())
|
if (c->type() != QEvent::ChildAdded || !c->child()->isWidgetType())
|
||||||
return;
|
return;
|
||||||
QWidget *w = (QWidget*)c->child();
|
QWidget *w = (QWidget*)c->child();
|
||||||
|
if (w->isWindow())
|
||||||
|
return;
|
||||||
if (d->checkable) {
|
if (d->checkable) {
|
||||||
if (d->checked) {
|
if (d->checked) {
|
||||||
if (!w->testAttribute(Qt::WA_ForceDisabled))
|
if (!w->testAttribute(Qt::WA_ForceDisabled))
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
#include <QStyleOptionGroupBox>
|
#include <QStyleOptionGroupBox>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
#include "qgroupbox.h"
|
#include "qgroupbox.h"
|
||||||
|
|
||||||
@ -71,6 +72,7 @@ private slots:
|
|||||||
void setChecked_data();
|
void setChecked_data();
|
||||||
void setChecked();
|
void setChecked();
|
||||||
void enabledPropagation();
|
void enabledPropagation();
|
||||||
|
void enabledChildPropagation();
|
||||||
void sizeHint();
|
void sizeHint();
|
||||||
void toggled();
|
void toggled();
|
||||||
void clicked_data();
|
void clicked_data();
|
||||||
@ -288,6 +290,23 @@ void tst_QGroupBox::enabledPropagation()
|
|||||||
delete testWidget;
|
delete testWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QGroupBox::enabledChildPropagation()
|
||||||
|
{
|
||||||
|
QGroupBox testWidget;
|
||||||
|
testWidget.setCheckable(true);
|
||||||
|
testWidget.setChecked(true);
|
||||||
|
// The value of isChecked() should be reflected in the isEnabled() of newly
|
||||||
|
// added child widgets, but not in top level widgets.
|
||||||
|
QWidget *childWidget = new QWidget(&testWidget);
|
||||||
|
QVERIFY(childWidget->isEnabled());
|
||||||
|
QDialog *dialog = new QDialog(&testWidget);
|
||||||
|
QVERIFY(dialog->isEnabled());
|
||||||
|
testWidget.setChecked(false);
|
||||||
|
childWidget = new QWidget(&testWidget);
|
||||||
|
QVERIFY(!childWidget->isEnabled());
|
||||||
|
dialog = new QDialog(&testWidget);
|
||||||
|
QVERIFY(dialog->isEnabled());
|
||||||
|
}
|
||||||
|
|
||||||
void tst_QGroupBox::sizeHint()
|
void tst_QGroupBox::sizeHint()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user