aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/text/fonts
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-09-17 18:10:59 +0200
committerUlf Hermann <ulf.hermann@qt.io>2020-02-11 19:26:05 +0100
commit90b4528b846542bfa6f0723487315140b9de17b4 (patch)
tree9356c0e6b5a736b3228ca6793416d927432c101e /examples/quick/text/fonts
parent38c03709236f6a2114ace7adf1b6bdcdfe8e4e18 (diff)
Avoid discouraged patterns in examples
In particular, use required properties where applicable, explicitly import QtQml where we use it, avoid unqualified access into the root scope of a component, use JavaScript functions with explicit parameters as signal handlers. Change-Id: I3eaaba47cc3c7a2a12d488e36f9eec145cedbb0e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'examples/quick/text/fonts')
-rw-r--r--examples/quick/text/fonts/availableFonts.qml5
-rw-r--r--examples/quick/text/fonts/fonts.qml13
2 files changed, 10 insertions, 8 deletions
diff --git a/examples/quick/text/fonts/availableFonts.qml b/examples/quick/text/fonts/availableFonts.qml
index ea3bff22b8..41dbae0021 100644
--- a/examples/quick/text/fonts/availableFonts.qml
+++ b/examples/quick/text/fonts/availableFonts.qml
@@ -61,11 +61,12 @@ Rectangle {
delegate: Item {
height: 40; width: ListView.view.width
+ required property string modelData
Text {
anchors.centerIn: parent
- text: modelData
+ text: parent.modelData
//! [delegate]
- font.family: modelData
+ font.family: parent.modelData
//! [delegate]
font.pixelSize: 20
color: "white"
diff --git a/examples/quick/text/fonts/fonts.qml b/examples/quick/text/fonts/fonts.qml
index d356e00417..4478db0135 100644
--- a/examples/quick/text/fonts/fonts.qml
+++ b/examples/quick/text/fonts/fonts.qml
@@ -51,6 +51,7 @@
import QtQuick 2.0
Rectangle {
+ id: root
property string myText: "The quick brown fox jumps over the lazy dog."
width: 320; height: 480
@@ -71,7 +72,7 @@ Rectangle {
spacing: 15
Text {
- text: myText
+ text: root.myText
color: "lightsteelblue"
width: parent.width
wrapMode: Text.WordWrap
@@ -81,7 +82,7 @@ Rectangle {
font.pixelSize: 20
}
Text {
- text: myText
+ text: root.myText
color: "lightsteelblue"
width: parent.width
wrapMode: Text.WordWrap
@@ -89,7 +90,7 @@ Rectangle {
font { family: "Times"; pixelSize: 20; capitalization: Font.AllUppercase }
}
Text {
- text: myText
+ text: root.myText
color: "lightsteelblue"
width: parent.width
horizontalAlignment: Text.AlignRight
@@ -97,14 +98,14 @@ Rectangle {
font { family: fixedFont.name; pixelSize: 20; weight: Font.Bold; capitalization: Font.AllLowercase }
}
Text {
- text: myText
+ text: root.myText
color: "lightsteelblue"
width: parent.width
wrapMode: Text.WordWrap
font { family: fixedFont.name; pixelSize: 20; italic: true; capitalization: Font.SmallCaps }
}
Text {
- text: myText
+ text: root.myText
color: "lightsteelblue"
width: parent.width
wrapMode: Text.WordWrap
@@ -112,7 +113,7 @@ Rectangle {
}
Text {
text: {
- if (webFont.status == FontLoader.Ready) myText
+ if (webFont.status == FontLoader.Ready) root.myText
else if (webFont.status == FontLoader.Loading) "Loading..."
else if (webFont.status == FontLoader.Error) "Error loading font"
}