Rectangles & padding
-
Hello
it seems I'm either very stupid in finding this information or it truly doesnt exist.
Do rectangles have a padding property or how is padding realized with the current functionality?Of Course you can nest 2 rectangles to get this effect and use margins in the inner rectangle
but thats kind of messes up what I'm trying to do.thanks for your time.
-
Padding what? Between what and what? If you're anchoring it to something else, you can specify margins / spacing via the anchors.
Cheers,
Chris. -
uhm..
something like this:
@
Rectangle{
padding:10Rectangle{
anchors.fill: parent
}
}
@That every Child inside a, say, Rectangle (Row, Column,.. etc) component will be positioned inside that said rectangle with an offset of 10 from each side..
that inner rectangle will be 20 px short in length and height in this example.
like the padidng property in css
-
It is the anchors which define how the child rectangle fills the parent rectangle. Remember, in QML, just because an object instance is declared within another one does NOT mean that it is visually located inside that other one. The positioning (either via anchors, or some other positioning method) define where it "appears" and thus the positioning also defines the spacing / padding.
So, to implement what you want, just add an "anchors.margins: 10" to your anchors declaration. Note that the margin can also be specified separately for each edge; see http://doc-snapshot.qt-project.org/qt5-stable/qtquick/qtquick-positioning-anchors.html for more information.
Cheers,
Chris.