diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2016-09-20 15:49:21 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-09-21 21:40:33 +0000 |
commit | 7193318330bc518255fb7ed008c144578f49b4bd (patch) | |
tree | fd4a26a78b5466d9d5e6f01e67ccabd69671382b /src | |
parent | 9dea203013c0a5d20fdffbb2b9a1c1dcc70435b1 (diff) |
Control: add example snippets for background, contentItem and font
Change-Id: I0968454452dcf17093ef27af8770fd5018780160
Task-number: QTBUG-55904
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/quicktemplates2/qquickcontrol.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp index 8c5c75d2..518255dd 100644 --- a/src/quicktemplates2/qquickcontrol.cpp +++ b/src/quicktemplates2/qquickcontrol.cpp @@ -454,6 +454,22 @@ void QQuickControl::itemChange(QQuickItem::ItemChange change, const QQuickItem:: Control propagates explicit font properties from parent to children. If you change a specific property on a control's font, that property propagates to all of the control's children, overriding any system defaults for that property. + + \code + Page { + font.family: "Courier" + + Column { + Label { + text: qsTr("This will use Courier...") + } + + Switch { + text: qsTr("... and so will this") + } + } + } + \endcode */ QFont QQuickControl::font() const { @@ -987,6 +1003,19 @@ void QQuickControl::setWheelEnabled(bool enabled) This property holds the background item. + \code + Button { + id: control + text: qsTr("Button") + background: Rectangle { + implicitWidth: 100 + implicitHeight: 40 + opacity: enabled ? 1 : 0.3 + color: control.down ? "#d0d0d0" : "#e0e0e0" + } + } + \endcode + \note If the background item has no explicit size specified, it automatically follows the control's size. In most cases, there is no need to specify width or height for a background item. @@ -1037,6 +1066,18 @@ void QQuickControl::setBackground(QQuickItem *background) size for it (unless it is an item like \l Text which has its own implicit size). + \code + Button { + id: control + text: qsTr("Button") + contentItem: Label { + text: control.text + font: control.font + verticalAlignment: Text.AlignVCenter + } + } + \endcode + \sa {Control Layout}, padding */ QQuickItem *QQuickControl::contentItem() const |