aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <[email protected]>2023-01-10 12:50:18 +0100
committerRichard Moe Gustavsen <[email protected]>2023-01-12 08:28:35 +0100
commitc5317b4b594fbc26de7fde2bc40d6c7ba092ee9b (patch)
treecdf12e711b2b3e5535943a7ca542744e84f6d310
parent84d69e4695c179e595d24928a6480852d7f5186f (diff)
HeaderView: ensure that the implicit size is greater than zero
HorizontalHeaderView should have the same implicit height as the delegate items it contains. And this height is reflected by contentHeight. The problem is that the content height is zero at start-up, before the view gets populated with delegate items. The result is that the height of the view will then be zero at start-up, which can lead to TableView not loading any items at all. This patch will therefore ensure that the implicit height of HeaderView is 1 at start-up, so that the delegate items will be loaded. Once loaded, the implicit height of the view will be adjusted to the correct value. Pick-to: 6.5 Change-Id: I5181840665f648275e28dd8fe943e759797388fa Reviewed-by: Mitch Curtis <[email protected]>
-rw-r--r--src/quickcontrols/basic/HorizontalHeaderView.qml7
-rw-r--r--src/quickcontrols/basic/VerticalHeaderView.qml7
-rw-r--r--src/quickcontrols/fusion/HorizontalHeaderView.qml7
-rw-r--r--src/quickcontrols/fusion/VerticalHeaderView.qml7
-rw-r--r--src/quickcontrols/imagine/HorizontalHeaderView.qml7
-rw-r--r--src/quickcontrols/imagine/VerticalHeaderView.qml7
-rw-r--r--src/quickcontrols/material/HorizontalHeaderView.qml7
-rw-r--r--src/quickcontrols/material/VerticalHeaderView.qml7
-rw-r--r--src/quickcontrols/universal/HorizontalHeaderView.qml7
-rw-r--r--src/quickcontrols/universal/VerticalHeaderView.qml7
10 files changed, 60 insertions, 10 deletions
diff --git a/src/quickcontrols/basic/HorizontalHeaderView.qml b/src/quickcontrols/basic/HorizontalHeaderView.qml
index 140c9f3ae8..a46cf31f49 100644
--- a/src/quickcontrols/basic/HorizontalHeaderView.qml
+++ b/src/quickcontrols/basic/HorizontalHeaderView.qml
@@ -8,7 +8,12 @@ T.HorizontalHeaderView {
id: control
implicitWidth: syncView ? syncView.width : 0
- implicitHeight: contentHeight
+ // The contentHeight of TableView will be zero at start-up, until the delegate
+ // items have been loaded. This means that even if the implicit height of
+ // HorizontalHeaderView should be the same as the content height in the end, we
+ // need to ensure that it has at least a height of 1 at start-up, otherwise
+ // TableView won't bother loading any delegates at all.
+ implicitHeight: Math.max(1, contentHeight)
delegate: Rectangle {
// Qt6: add cellPadding (and font etc) as public API in headerview
diff --git a/src/quickcontrols/basic/VerticalHeaderView.qml b/src/quickcontrols/basic/VerticalHeaderView.qml
index a59e228d20..5ff9043f93 100644
--- a/src/quickcontrols/basic/VerticalHeaderView.qml
+++ b/src/quickcontrols/basic/VerticalHeaderView.qml
@@ -7,7 +7,12 @@ import QtQuick.Templates as T
T.VerticalHeaderView {
id: control
- implicitWidth: contentWidth
+ // The contentWidth of TableView will be zero at start-up, until the delegate
+ // items have been loaded. This means that even if the implicit width of
+ // VerticalHeaderView should be the same as the content width in the end, we
+ // need to ensure that it has at least a width of 1 at start-up, otherwise
+ // TableView won't bother loading any delegates at all.
+ implicitWidth: Math.max(1, contentWidth)
implicitHeight: syncView ? syncView.height : 0
delegate: Rectangle {
diff --git a/src/quickcontrols/fusion/HorizontalHeaderView.qml b/src/quickcontrols/fusion/HorizontalHeaderView.qml
index aafe0fb2fd..8a84c6142b 100644
--- a/src/quickcontrols/fusion/HorizontalHeaderView.qml
+++ b/src/quickcontrols/fusion/HorizontalHeaderView.qml
@@ -8,7 +8,12 @@ T.HorizontalHeaderView {
id: control
implicitWidth: syncView ? syncView.width : 0
- implicitHeight: contentHeight
+ // The contentHeight of TableView will be zero at start-up, until the delegate
+ // items have been loaded. This means that even if the implicit height of
+ // HorizontalHeaderView should be the same as the content height in the end, we
+ // need to ensure that it has at least a height of 1 at start-up, otherwise
+ // TableView won't bother loading any delegates at all.
+ implicitHeight: Math.max(1, contentHeight)
delegate: Rectangle {
// Qt6: add cellPadding (and font etc) as public API in headerview
diff --git a/src/quickcontrols/fusion/VerticalHeaderView.qml b/src/quickcontrols/fusion/VerticalHeaderView.qml
index 7ae2fcdd62..2e9ef6d753 100644
--- a/src/quickcontrols/fusion/VerticalHeaderView.qml
+++ b/src/quickcontrols/fusion/VerticalHeaderView.qml
@@ -7,7 +7,12 @@ import QtQuick.Templates as T
T.VerticalHeaderView {
id: control
- implicitWidth: contentWidth
+ // The contentWidth of TableView will be zero at start-up, until the delegate
+ // items have been loaded. This means that even if the implicit width of
+ // VerticalHeaderView should be the same as the content width in the end, we
+ // need to ensure that it has at least a width of 1 at start-up, otherwise
+ // TableView won't bother loading any delegates at all.
+ implicitWidth: Math.max(1, contentWidth)
implicitHeight: syncView ? syncView.height : 0
delegate: Rectangle {
diff --git a/src/quickcontrols/imagine/HorizontalHeaderView.qml b/src/quickcontrols/imagine/HorizontalHeaderView.qml
index 140c9f3ae8..a46cf31f49 100644
--- a/src/quickcontrols/imagine/HorizontalHeaderView.qml
+++ b/src/quickcontrols/imagine/HorizontalHeaderView.qml
@@ -8,7 +8,12 @@ T.HorizontalHeaderView {
id: control
implicitWidth: syncView ? syncView.width : 0
- implicitHeight: contentHeight
+ // The contentHeight of TableView will be zero at start-up, until the delegate
+ // items have been loaded. This means that even if the implicit height of
+ // HorizontalHeaderView should be the same as the content height in the end, we
+ // need to ensure that it has at least a height of 1 at start-up, otherwise
+ // TableView won't bother loading any delegates at all.
+ implicitHeight: Math.max(1, contentHeight)
delegate: Rectangle {
// Qt6: add cellPadding (and font etc) as public API in headerview
diff --git a/src/quickcontrols/imagine/VerticalHeaderView.qml b/src/quickcontrols/imagine/VerticalHeaderView.qml
index a59e228d20..5ff9043f93 100644
--- a/src/quickcontrols/imagine/VerticalHeaderView.qml
+++ b/src/quickcontrols/imagine/VerticalHeaderView.qml
@@ -7,7 +7,12 @@ import QtQuick.Templates as T
T.VerticalHeaderView {
id: control
- implicitWidth: contentWidth
+ // The contentWidth of TableView will be zero at start-up, until the delegate
+ // items have been loaded. This means that even if the implicit width of
+ // VerticalHeaderView should be the same as the content width in the end, we
+ // need to ensure that it has at least a width of 1 at start-up, otherwise
+ // TableView won't bother loading any delegates at all.
+ implicitWidth: Math.max(1, contentWidth)
implicitHeight: syncView ? syncView.height : 0
delegate: Rectangle {
diff --git a/src/quickcontrols/material/HorizontalHeaderView.qml b/src/quickcontrols/material/HorizontalHeaderView.qml
index 671728c004..a90c4f0d75 100644
--- a/src/quickcontrols/material/HorizontalHeaderView.qml
+++ b/src/quickcontrols/material/HorizontalHeaderView.qml
@@ -10,7 +10,12 @@ T.HorizontalHeaderView {
id: control
implicitWidth: syncView ? syncView.width : 0
- implicitHeight: contentHeight
+ // The contentHeight of TableView will be zero at start-up, until the delegate
+ // items have been loaded. This means that even if the implicit height of
+ // HorizontalHeaderView should be the same as the content height in the end, we
+ // need to ensure that it has at least a height of 1 at start-up, otherwise
+ // TableView won't bother loading any delegates at all.
+ implicitHeight: Math.max(1, contentHeight)
delegate: Rectangle {
// Qt6: add cellPadding (and font etc) as public API in headerview
diff --git a/src/quickcontrols/material/VerticalHeaderView.qml b/src/quickcontrols/material/VerticalHeaderView.qml
index e497d4a84c..f7b7ce9b5e 100644
--- a/src/quickcontrols/material/VerticalHeaderView.qml
+++ b/src/quickcontrols/material/VerticalHeaderView.qml
@@ -9,7 +9,12 @@ import QtQuick.Controls.Material.impl
T.VerticalHeaderView {
id: control
- implicitWidth: contentWidth
+ // The contentWidth of TableView will be zero at start-up, until the delegate
+ // items have been loaded. This means that even if the implicit width of
+ // VerticalHeaderView should be the same as the content width in the end, we
+ // need to ensure that it has at least a width of 1 at start-up, otherwise
+ // TableView won't bother loading any delegates at all.
+ implicitWidth: Math.max(1, contentWidth)
implicitHeight: syncView ? syncView.height : 0
delegate: Rectangle {
diff --git a/src/quickcontrols/universal/HorizontalHeaderView.qml b/src/quickcontrols/universal/HorizontalHeaderView.qml
index 878fb1e10e..3700008e92 100644
--- a/src/quickcontrols/universal/HorizontalHeaderView.qml
+++ b/src/quickcontrols/universal/HorizontalHeaderView.qml
@@ -11,7 +11,12 @@ T.HorizontalHeaderView {
id: control
implicitWidth: syncView ? syncView.width : 0
- implicitHeight: contentHeight
+ // The contentHeight of TableView will be zero at start-up, until the delegate
+ // items have been loaded. This means that even if the implicit height of
+ // HorizontalHeaderView should be the same as the content height in the end, we
+ // need to ensure that it has at least a height of 1 at start-up, otherwise
+ // TableView won't bother loading any delegates at all.
+ implicitHeight: Math.max(1, contentHeight)
delegate: Rectangle {
// Qt6: add cellPadding (and font etc) as public API in headerview
diff --git a/src/quickcontrols/universal/VerticalHeaderView.qml b/src/quickcontrols/universal/VerticalHeaderView.qml
index 189bed0906..43f8e6aeb8 100644
--- a/src/quickcontrols/universal/VerticalHeaderView.qml
+++ b/src/quickcontrols/universal/VerticalHeaderView.qml
@@ -10,7 +10,12 @@ import QtQuick.Controls.Universal.impl
T.VerticalHeaderView {
id: control
- implicitWidth: contentWidth
+ // The contentWidth of TableView will be zero at start-up, until the delegate
+ // items have been loaded. This means that even if the implicit width of
+ // VerticalHeaderView should be the same as the content width in the end, we
+ // need to ensure that it has at least a width of 1 at start-up, otherwise
+ // TableView won't bother loading any delegates at all.
+ implicitWidth: Math.max(1, contentWidth)
implicitHeight: syncView ? syncView.height : 0
delegate: Rectangle {