diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-06-09 22:31:40 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-06-09 20:33:12 +0000 |
commit | c33d11c27924dd5b405b3de74f1644486767c073 (patch) | |
tree | db4ab3dac295623103ddc995334d779f76ceaa03 /src | |
parent | c9fd039faac4c7a04f1a47ad0e96ca929aa5c2ca (diff) |
CheckBox docs
Change-Id: I7476a94fcae656ca11424681363228cfa2b99c6f
Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/controls/doc/images/qtquickcontrols2-checkbox-background.png | bin | 0 -> 2219 bytes | |||
-rw-r--r-- | src/controls/doc/images/qtquickcontrols2-checkbox-checked.png | bin | 0 -> 1884 bytes | |||
-rw-r--r-- | src/controls/doc/images/qtquickcontrols2-checkbox-disabled.png | bin | 0 -> 1898 bytes | |||
-rw-r--r-- | src/controls/doc/images/qtquickcontrols2-checkbox-focused.png | bin | 0 -> 1772 bytes | |||
-rw-r--r-- | src/controls/doc/images/qtquickcontrols2-checkbox-indicator.png | bin | 0 -> 2088 bytes | |||
-rw-r--r-- | src/controls/doc/images/qtquickcontrols2-checkbox-label.png | bin | 0 -> 2159 bytes | |||
-rw-r--r-- | src/controls/doc/images/qtquickcontrols2-checkbox-normal.png | bin | 0 -> 1437 bytes | |||
-rw-r--r-- | src/controls/qquickcheckable.cpp | 6 | ||||
-rw-r--r-- | src/controls/qquickcheckbox.cpp | 59 | ||||
-rw-r--r-- | src/imports/controls/CheckBox.qml | 4 |
10 files changed, 65 insertions, 4 deletions
diff --git a/src/controls/doc/images/qtquickcontrols2-checkbox-background.png b/src/controls/doc/images/qtquickcontrols2-checkbox-background.png Binary files differnew file mode 100644 index 00000000..81198821 --- /dev/null +++ b/src/controls/doc/images/qtquickcontrols2-checkbox-background.png diff --git a/src/controls/doc/images/qtquickcontrols2-checkbox-checked.png b/src/controls/doc/images/qtquickcontrols2-checkbox-checked.png Binary files differnew file mode 100644 index 00000000..f44428e0 --- /dev/null +++ b/src/controls/doc/images/qtquickcontrols2-checkbox-checked.png diff --git a/src/controls/doc/images/qtquickcontrols2-checkbox-disabled.png b/src/controls/doc/images/qtquickcontrols2-checkbox-disabled.png Binary files differnew file mode 100644 index 00000000..ca31061a --- /dev/null +++ b/src/controls/doc/images/qtquickcontrols2-checkbox-disabled.png diff --git a/src/controls/doc/images/qtquickcontrols2-checkbox-focused.png b/src/controls/doc/images/qtquickcontrols2-checkbox-focused.png Binary files differnew file mode 100644 index 00000000..7847fb9b --- /dev/null +++ b/src/controls/doc/images/qtquickcontrols2-checkbox-focused.png diff --git a/src/controls/doc/images/qtquickcontrols2-checkbox-indicator.png b/src/controls/doc/images/qtquickcontrols2-checkbox-indicator.png Binary files differnew file mode 100644 index 00000000..7c6148b6 --- /dev/null +++ b/src/controls/doc/images/qtquickcontrols2-checkbox-indicator.png diff --git a/src/controls/doc/images/qtquickcontrols2-checkbox-label.png b/src/controls/doc/images/qtquickcontrols2-checkbox-label.png Binary files differnew file mode 100644 index 00000000..5bef6df5 --- /dev/null +++ b/src/controls/doc/images/qtquickcontrols2-checkbox-label.png diff --git a/src/controls/doc/images/qtquickcontrols2-checkbox-normal.png b/src/controls/doc/images/qtquickcontrols2-checkbox-normal.png Binary files differnew file mode 100644 index 00000000..790ebc93 --- /dev/null +++ b/src/controls/doc/images/qtquickcontrols2-checkbox-normal.png diff --git a/src/controls/qquickcheckable.cpp b/src/controls/qquickcheckable.cpp index 24abb5f9..2f6381c1 100644 --- a/src/controls/qquickcheckable.cpp +++ b/src/controls/qquickcheckable.cpp @@ -66,7 +66,7 @@ QQuickCheckable::QQuickCheckable(QQuickCheckablePrivate &dd, QQuickItem *parent) /*! \qmlproperty bool QtQuickControls2::Checkable::checked - TODO + This property holds whether the control is checked. */ bool QQuickCheckable::isChecked() const { @@ -98,7 +98,7 @@ void QQuickCheckable::setExclusive(bool exclusive) /*! \qmlproperty Item QtQuickControls2::Checkable::indicator - TODO + This property holds the indicator item. */ QQuickItem *QQuickCheckable::indicator() const { @@ -124,7 +124,7 @@ void QQuickCheckable::setIndicator(QQuickItem *indicator) /*! \qmlmethod void QtQuickControls2::Checkable::toggle() - TODO + Toggles the checked state of the control. */ void QQuickCheckable::toggle() { diff --git a/src/controls/qquickcheckbox.cpp b/src/controls/qquickcheckbox.cpp index 680b3b13..cc314053 100644 --- a/src/controls/qquickcheckbox.cpp +++ b/src/controls/qquickcheckbox.cpp @@ -46,7 +46,64 @@ QT_BEGIN_NAMESPACE \ingroup buttons \brief A check box control. - TODO + CheckBox presents an option button that can be toggled on (checked) or + off (unchecked). Check boxes are typically used to select one or more + options from a set of options. + + \table + \row \li \image qtquickcontrols2-checkbox-normal.png + \li A check box in its normal state. + \row \li \image qtquickcontrols2-checkbox-checked.png + \li A check box that is checked. + \row \li \image qtquickcontrols2-checkbox-focused.png + \li A check box that has active focus. + \row \li \image qtquickcontrols2-checkbox-disabled.png + \li A check box that is disabled. + \endtable + + \code + ColumnLayout { + CheckBox { + checked: true + text: qsTr("First") + } + CheckBox { + text: qsTr("Second") + } + CheckBox { + checked: true + text: qsTr("Third") + } + } + \endcode + + \section1 Structure + + CheckBox consists of three parts, \l {Control::background}{background}, + \l {Button::label}{label} and \l {Checkable::indicator}{indicator}. Their + implicit sizes are used to calculate the implicit size of the control. + + \section3 Background + + \image qtquickcontrols2-checkbox-background.png + + CheckBox has no background item by default. + + \section3 Label + + \image qtquickcontrols2-checkbox-label.png + + The following snippet presents the default label item implementation. + + \snippet CheckBox.qml label + + \section3 Indicator + + \image qtquickcontrols2-checkbox-indicator.png + + The following snippet presents the default indicator item implementation. + + \snippet CheckBox.qml indicator */ QQuickCheckBox::QQuickCheckBox(QQuickItem *parent) : diff --git a/src/imports/controls/CheckBox.qml b/src/imports/controls/CheckBox.qml index c250b54a..9e71dda9 100644 --- a/src/imports/controls/CheckBox.qml +++ b/src/imports/controls/CheckBox.qml @@ -55,6 +55,7 @@ AbstractCheckBox { padding: Theme.padding + //! [indicator] indicator: Rectangle { implicitWidth: 20 implicitHeight: 20 @@ -79,7 +80,9 @@ AbstractCheckBox { border.color: control.Theme.frameColor } } + //! [indicator] + //! [label] label: Text { x: control.mirrored ? control.leftPadding : (indicator.x + indicator.width + control.Theme.spacing) y: control.topPadding @@ -93,4 +96,5 @@ AbstractCheckBox { horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } + //! [label] } |