2
1
Fork 0

guide: add positioning overview

This commit is contained in:
outfoxxed 2024-04-15 03:59:17 -07:00
parent 97b2c23f9f
commit 7c6cdbcd7b
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
2 changed files with 111 additions and 19 deletions

View file

@ -599,19 +599,13 @@ single `Text` object but the same concepts apply regardless of complexity.
```qml {filename="ClockWidget.qml"}
import QtQuick
// Item is a common base type for visual components
Item {
// make a property the creator of this type is required to set
Text {
// A property the creator of this type is required to set.
// Note that we could just set `text` instead, but don't because your
// clock probably will not be this simple.
required property string time
// size the item to its children
width: childrenRect.width
height: childrenRect.height
// use the default property to contain the clock
Text {
text: time
}
text: time
}
```
@ -774,16 +768,11 @@ Singleton {
```qml {filename="ClockWidget.qml"}
import QtQuick
Item {
Text {
// we no longer need time as an input
width: childrenRect.width
height: childrenRect.height
Text {
// directly access the time property from the Time singleton
text: Time.time
}
// directly access the time property from the Time singleton
text: Time.time
}
```