How to size constrain a ColumnLayout?
-
Hi all -
My main window uses this code:
import QtQml import QtQuick import QtQuick.Controls import QtQuick.Controls.Fusion import QtQuick.Controls.Basic import QtQuick.Controls.Material import QtQuick.Controls.Universal import QtQuick.Layouts ApplicationWindow { id: mainWindow readonly property real margin: width / 32.0 visible: true width: 800 height: 480 menuBar: Maintabbar { id: navBar height: 56 width: mainWindow.width } ColumnLayout { id: mainLayout height: mainWindow.height - navBar.height - mainWindow.margin width: mainWindow.width anchors { fill: parent leftMargin: margin rightMargin: margin bottomMargin: margin } Maincontent { id: mainContent // stuff here } } }
I'm trying to get a margin on the sides and bottom of mainLayout. The left and right margins seem to be working, but my mainContent goes all the way to the bottom of the screen. Resizing the ColumnLayout doesn't seem to help. Any ideas what I'm missing here?
Thanks...
-
Hi all -
My main window uses this code:
import QtQml import QtQuick import QtQuick.Controls import QtQuick.Controls.Fusion import QtQuick.Controls.Basic import QtQuick.Controls.Material import QtQuick.Controls.Universal import QtQuick.Layouts ApplicationWindow { id: mainWindow readonly property real margin: width / 32.0 visible: true width: 800 height: 480 menuBar: Maintabbar { id: navBar height: 56 width: mainWindow.width } ColumnLayout { id: mainLayout height: mainWindow.height - navBar.height - mainWindow.margin width: mainWindow.width anchors { fill: parent leftMargin: margin rightMargin: margin bottomMargin: margin } Maincontent { id: mainContent // stuff here } } }
I'm trying to get a margin on the sides and bottom of mainLayout. The left and right margins seem to be working, but my mainContent goes all the way to the bottom of the screen. Resizing the ColumnLayout doesn't seem to help. Any ideas what I'm missing here?
Thanks...
-
@JoeCFD said in How to size constrain a ColumnLayout?:
@mzimmers How do you set the size of Maincontent?
Well, that's in flux, too. Ideally, I'd like to have it fill the available area. (There are a couple items above Maincontent that I left out of my snippet.) I've tried:
Layout.fillHeight: true Layout.fillWidth: true
but that doesn't work (in fact, it doesn't seem to have any effect, which is odd).
If there's a better way to size it, I'm open.
-
Hi all -
My main window uses this code:
import QtQml import QtQuick import QtQuick.Controls import QtQuick.Controls.Fusion import QtQuick.Controls.Basic import QtQuick.Controls.Material import QtQuick.Controls.Universal import QtQuick.Layouts ApplicationWindow { id: mainWindow readonly property real margin: width / 32.0 visible: true width: 800 height: 480 menuBar: Maintabbar { id: navBar height: 56 width: mainWindow.width } ColumnLayout { id: mainLayout height: mainWindow.height - navBar.height - mainWindow.margin width: mainWindow.width anchors { fill: parent leftMargin: margin rightMargin: margin bottomMargin: margin } Maincontent { id: mainContent // stuff here } } }
I'm trying to get a margin on the sides and bottom of mainLayout. The left and right margins seem to be working, but my mainContent goes all the way to the bottom of the screen. Resizing the ColumnLayout doesn't seem to help. Any ideas what I'm missing here?
Thanks...
@mzimmers said in How to size constrain a ColumnLayout?:
but my mainContent goes all the way to the bottom of the screen. Resizing the ColumnLayout doesn't seem to help
maybe stupid question : if the mainContent goes beyond the margins, wouldn't this simply be a clipping problem ?
-
@mzimmers said in How to size constrain a ColumnLayout?:
but my mainContent goes all the way to the bottom of the screen. Resizing the ColumnLayout doesn't seem to help
maybe stupid question : if the mainContent goes beyond the margins, wouldn't this simply be a clipping problem ?
@ankou29666 mainContent is a StackLayout of various ColumnLayouts. I'm not sure where I'd apply the clipping.
What I'm hoping for is to contain the size somewhere at the top level of my heirarchy so that everything underneath will observe it.
-
@ankou29666 mainContent is a StackLayout of various ColumnLayouts. I'm not sure where I'd apply the clipping.
What I'm hoping for is to contain the size somewhere at the top level of my heirarchy so that everything underneath will observe it.
@mzimmers
this code works fine on Linux. Windows problem again?import QtQml import QtQuick import QtQuick.Controls import QtQuick.Controls.Fusion import QtQuick.Controls.Basic import QtQuick.Controls.Material import QtQuick.Controls.Universal import QtQuick.Layouts ApplicationWindow { id: mainWindow readonly property real margin: width / 32.0 visible: true width: 800 height: 480 menuBar: Rectangle { id: navBar height: 56 width: mainWindow.width } ColumnLayout { id: mainLayout height: mainWindow.height - navBar.height - mainWindow.margin width: mainWindow.width anchors { fill: parent leftMargin: margin rightMargin: margin bottomMargin: margin } TextArea { id: mainContent Layout.fillHeight: true Layout.fillWidth: true } } }
-
@mzimmers
this code works fine on Linux. Windows problem again?import QtQml import QtQuick import QtQuick.Controls import QtQuick.Controls.Fusion import QtQuick.Controls.Basic import QtQuick.Controls.Material import QtQuick.Controls.Universal import QtQuick.Layouts ApplicationWindow { id: mainWindow readonly property real margin: width / 32.0 visible: true width: 800 height: 480 menuBar: Rectangle { id: navBar height: 56 width: mainWindow.width } ColumnLayout { id: mainLayout height: mainWindow.height - navBar.height - mainWindow.margin width: mainWindow.width anchors { fill: parent leftMargin: margin rightMargin: margin bottomMargin: margin } TextArea { id: mainContent Layout.fillHeight: true Layout.fillWidth: true } } }
@JoeCFD no, it works OK here, too. I even put a few things above your TextArea; still works.
I replaced my Maincontent with a Rectangle, and it works fine, so there's something in my Maincontent that's ignoring the boundaries of the ColumnLayout. I'll have to dig a little to figure out what that is. I wish there were a way to force all children items to respect the boundaries of a parent, though.
-
@JoeCFD no, it works OK here, too. I even put a few things above your TextArea; still works.
I replaced my Maincontent with a Rectangle, and it works fine, so there's something in my Maincontent that's ignoring the boundaries of the ColumnLayout. I'll have to dig a little to figure out what that is. I wish there were a way to force all children items to respect the boundaries of a parent, though.
@mzimmers From what I read from this page https://doc.qt.io/qt-6/qml-qtquick-layouts-layout.html#fillHeight-attached-prop
layout.fillHeight/Width is false by default excepted for layout themselves (that is if I understand it right, layout nested in another layout). But as this is what you obviously want this is obviously not the problem. However check and see if there might be another "subtility" with layout inside another layout that might cause the problem.
-
@mzimmers From what I read from this page https://doc.qt.io/qt-6/qml-qtquick-layouts-layout.html#fillHeight-attached-prop
layout.fillHeight/Width is false by default excepted for layout themselves (that is if I understand it right, layout nested in another layout). But as this is what you obviously want this is obviously not the problem. However check and see if there might be another "subtility" with layout inside another layout that might cause the problem.
@ankou29666 it turns out that the problem only occurs when I use a Module I created to create a custom list display. I'm going to close this topic and start a new one focused on that.
Thanks to all who looked...
-
M mzimmers has marked this topic as solved on