From 8bf7ebe4d7d3de209c2c0993a02245f4c0625a6f Mon Sep 17 00:00:00 2001 From: Fatih Uzunoglu Date: Wed, 21 Aug 2024 19:09:45 +0300 Subject: [PATCH] qml: set content height when orientation is horizontal in ListViewExt We were already setting the content width, primarily for vertical list view. However, there is no restriction as such that ListViewExt can not be used in horizontal orientation. By default, list view does not estimate content height when the orientation is horizontal. However, in most cases if not all, the delegate uses the content size to set its size. For example, in a vertical list view, it is sensible that the delegate uses content width to determine its width. If the delegate does not set its width when orientation is vertical, or height when orientation is horizontal based on content width and height, respectively, then it is the view's responsibility to override the content size. --- modules/gui/qt/widgets/qml/ListViewExt.qml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/gui/qt/widgets/qml/ListViewExt.qml b/modules/gui/qt/widgets/qml/ListViewExt.qml index 2b28a696a6f9..50e5dcfca4b5 100644 --- a/modules/gui/qt/widgets/qml/ListViewExt.qml +++ b/modules/gui/qt/widgets/qml/ListViewExt.qml @@ -98,10 +98,11 @@ ListView { section.criteria: ViewSection.FullString section.delegate: sectionHeading - // Content width is set to the width by default + // Content size is set to the size by default // If the delegate does not obey it, calculate - // the content width appropriately. + // the content size appropriately. contentWidth: (orientation === ListView.Vertical) ? width - (leftMargin + rightMargin) : -1 + contentHeight: (orientation === ListView.Horizontal) ? height - (topMargin + bottomMargin) : -1 footer: !!root.acceptDropFunc ? footerDragAccessoryComponent : null