diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-11-01 19:18:31 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-11-03 09:35:49 +0000 |
commit | a108298bb9529dd1ad4b195849f3c1e12daa82bf (patch) | |
tree | 73510314439ab8c13764d1ed906b7e9154d53d15 /src/templates/qquickradiobutton.cpp | |
parent | 92aa5333846081b294fc332e64f7e49b329edf92 (diff) |
Add AbstractButton::autoExclusive
This feature is adopted from QtWidgets' QAbstractButton. It's no longer
necessary to create an ExclusiveGroup to manage a simple list of radio
buttons:
Column {
RadioButton { text: "Option 1" }
RadioButton { text: "Option 2" }
}
Change-Id: Ib4cb718c3b3034c9c956b2f23db4b06b00547b8e
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'src/templates/qquickradiobutton.cpp')
-rw-r--r-- | src/templates/qquickradiobutton.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/templates/qquickradiobutton.cpp b/src/templates/qquickradiobutton.cpp index 7a94248a..92a14394 100644 --- a/src/templates/qquickradiobutton.cpp +++ b/src/templates/qquickradiobutton.cpp @@ -61,21 +61,22 @@ QT_BEGIN_NAMESPACE \li A radio button that is disabled. \endtable + Radio buttons are \l {AbstractButton::autoExclusive}{auto-exclusive} + by default. Only one button can be checked at any time amongst radio + buttons that belong to the same parent item; checking another button + automatically unchecks the previously checked one. + \code ColumnLayout { - ExclusiveGroup { id: group } RadioButton { checked: true text: qsTr("First") - ExclusiveGroup.group: group } RadioButton { text: qsTr("Second") - ExclusiveGroup.group: group } RadioButton { text: qsTr("Third") - ExclusiveGroup.group: group } } \endcode @@ -87,7 +88,7 @@ QQuickRadioButton::QQuickRadioButton(QQuickItem *parent) : QQuickAbstractButton(parent) { setCheckable(true); - setExclusive(true); + setAutoExclusive(true); } #ifndef QT_NO_ACCESSIBILITY |