diff options
author | Jasper Ras <jaspert.ras@gmail.com> | 2025-07-24 21:24:53 +0200 |
---|---|---|
committer | Jasper Ras <jaspert.ras@gmail.com> | 2025-07-24 21:24:53 +0200 |
commit | 8bde51ba29aa23d1b6e01826b6af720b4256bd78 (patch) | |
tree | 82598f27262208fb0792fad61d26259340b9ba35 /Item Size Position.md | |
parent | 1dbacfecb241f5eb6b512f78b0b243615b971c1a (diff) |
quickshell
Diffstat (limited to 'Item Size Position.md')
-rw-r--r-- | Item Size Position.md | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/Item Size Position.md b/Item Size Position.md new file mode 100644 index 0000000..2479688 --- /dev/null +++ b/Item Size Position.md @@ -0,0 +1,40 @@ +[[Quickshell]] + +--- + +# Item Size Position + +`Item` type is the base type for "visual items". It has two properties: +- actual size ( width, height ) +- implicit/desired size ( implicitWidth, implicitHeight ) + +Implicit size is used by containers to determine their own. + +## Container items + +Container (ie. `Item`): +```qml +implicitWidth: child.implicitWidth + margin * 2 +implicitHeight: child.implicitHeight + margin * 2 +``` + +^ `WrapperItem` does this margin for us. + +Child (ie. `Rectangle`): +```qml +x: parent.margin +y: parent.margin +width: parent.width - parent.margin * 2 +height: parent.height - parent.margin * 2 +implicitWidth: 50 +implicitHeight: 50 +``` +[Binding](https://doc.qt.io/qt-6/qml-qtqml-binding.html) can be used to map any property +[Anchors](https://doc.qt.io/qt-6/qtquick-positioning-anchors.html) are a shorthand way to achieve many common position and size bindings. + +Using a containers' Item.childrenRect to determine size of children is a mistake. +Item.childrenRect represents the actual geometry of all child items, not the mplicit one. + +Use [MarginWrapperManager](https://quickshell.org/docs/types/Quickshell.Widgets/MarginWrapperManager) to handle size and position of container and a single child item. + +## Layouts |