aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2015-06-09 22:31:40 +0200
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2015-06-09 20:33:12 +0000
commitc33d11c27924dd5b405b3de74f1644486767c073 (patch)
treedb4ab3dac295623103ddc995334d779f76ceaa03 /src
parentc9fd039faac4c7a04f1a47ad0e96ca929aa5c2ca (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.pngbin0 -> 2219 bytes
-rw-r--r--src/controls/doc/images/qtquickcontrols2-checkbox-checked.pngbin0 -> 1884 bytes
-rw-r--r--src/controls/doc/images/qtquickcontrols2-checkbox-disabled.pngbin0 -> 1898 bytes
-rw-r--r--src/controls/doc/images/qtquickcontrols2-checkbox-focused.pngbin0 -> 1772 bytes
-rw-r--r--src/controls/doc/images/qtquickcontrols2-checkbox-indicator.pngbin0 -> 2088 bytes
-rw-r--r--src/controls/doc/images/qtquickcontrols2-checkbox-label.pngbin0 -> 2159 bytes
-rw-r--r--src/controls/doc/images/qtquickcontrols2-checkbox-normal.pngbin0 -> 1437 bytes
-rw-r--r--src/controls/qquickcheckable.cpp6
-rw-r--r--src/controls/qquickcheckbox.cpp59
-rw-r--r--src/imports/controls/CheckBox.qml4
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
new file mode 100644
index 00000000..81198821
--- /dev/null
+++ b/src/controls/doc/images/qtquickcontrols2-checkbox-background.png
Binary files differ
diff --git a/src/controls/doc/images/qtquickcontrols2-checkbox-checked.png b/src/controls/doc/images/qtquickcontrols2-checkbox-checked.png
new file mode 100644
index 00000000..f44428e0
--- /dev/null
+++ b/src/controls/doc/images/qtquickcontrols2-checkbox-checked.png
Binary files differ
diff --git a/src/controls/doc/images/qtquickcontrols2-checkbox-disabled.png b/src/controls/doc/images/qtquickcontrols2-checkbox-disabled.png
new file mode 100644
index 00000000..ca31061a
--- /dev/null
+++ b/src/controls/doc/images/qtquickcontrols2-checkbox-disabled.png
Binary files differ
diff --git a/src/controls/doc/images/qtquickcontrols2-checkbox-focused.png b/src/controls/doc/images/qtquickcontrols2-checkbox-focused.png
new file mode 100644
index 00000000..7847fb9b
--- /dev/null
+++ b/src/controls/doc/images/qtquickcontrols2-checkbox-focused.png
Binary files differ
diff --git a/src/controls/doc/images/qtquickcontrols2-checkbox-indicator.png b/src/controls/doc/images/qtquickcontrols2-checkbox-indicator.png
new file mode 100644
index 00000000..7c6148b6
--- /dev/null
+++ b/src/controls/doc/images/qtquickcontrols2-checkbox-indicator.png
Binary files differ
diff --git a/src/controls/doc/images/qtquickcontrols2-checkbox-label.png b/src/controls/doc/images/qtquickcontrols2-checkbox-label.png
new file mode 100644
index 00000000..5bef6df5
--- /dev/null
+++ b/src/controls/doc/images/qtquickcontrols2-checkbox-label.png
Binary files differ
diff --git a/src/controls/doc/images/qtquickcontrols2-checkbox-normal.png b/src/controls/doc/images/qtquickcontrols2-checkbox-normal.png
new file mode 100644
index 00000000..790ebc93
--- /dev/null
+++ b/src/controls/doc/images/qtquickcontrols2-checkbox-normal.png
Binary files differ
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]
}