From 7193318330bc518255fb7ed008c144578f49b4bd Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 20 Sep 2016 15:49:21 +0200 Subject: Control: add example snippets for background, contentItem and font Change-Id: I0968454452dcf17093ef27af8770fd5018780160 Task-number: QTBUG-55904 Reviewed-by: J-P Nurmi --- src/quicktemplates2/qquickcontrol.cpp | 41 +++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) 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 -- cgit v1.2.3