Internal margin / padding for Column/Row layout?
-
Hi,
I'm pretty familiar with positioning: anchors, its margins and width/height bindings with parent but I'm still confused with some things. I'm trying to avoidwidth: parent.widthbinding because I read in some Qt doc that it has performance affect and better use anchors.I'm wondering why
RowLayoutandColumnLayoutdon't havepaddingproperty. If I want to have some extra spacing around whole control (or layout) then I need to anchor it somewhere and then useanchor.marginsor in layout's items setLayout.marginsbut in this case I have to set it for each row/column. For example simpleRow {}positioner haspaddingproperty which set offser arround whole layout and this is exactly what I want, whyRowLayoutandColumnLayoutdon't have it? Reason why I can't useRow{}because I can't figure out how to set item width to maximum like inRowLayoutwhere I just setTextField { Layout.fillWidth: true }Real example.
ApplicationWindowandheaderApplicationWindow { header: TextField { id: headerBar }With above, TextField has some default width and I would like to have it filled with application width. I could use
width: parent.width, I know, but as I mentioned earlier, I would like avoid it. And header will have multiple rows so I have to use some layout anyway.The general reason why I'm asking this question is that I don't like that whole
ApplicationWindowdoesn't have any margins. Everything is just positioned at x:0 and y:0 which looks weird. My goal is to set some margin for whole application. In Qt Widgetsets, layouts works different. I can set main layout for all widgets in main form and this layout has margins which affects whole main form borders -
use a Page{} inside your ApplicationWindow, then add header
-
K Kobid has marked this topic as solved on
-
Thanks. Indeed this helped.
ApplicationWindow { Page { id: mainPage anchors.fill: parent anchors.margins: 10 header: MyHeaderBar { } footer: MyFooter{ } ListView { anchors.fill: parent clip: true } }Now with
anchors.margins: 10I have a global padding arround my whole application including footer, header and content items. Perfect