From f7662366b120c1cacd43a2c2ae36b03f578d7478 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sun, 28 Jul 2024 12:45:28 +0200 Subject: [PATCH] Tests/QTreeView: make styleOptionViewItem more robust styleOptionViewItem() sometimes fails due to a very small widget size even when using showMaximized(). This might be due to a mis-configured vm scrren size or similar. To make sure that all 4 rows are properly painted set the minimum width to a reasonable value and also resize the sections appropriately. Pick-to: 6.8 6.7 6.5 Fixes: QTBUG-126494 Change-Id: I9956d3119be1ba9e0fb33e4e7b30f40b01b017a5 Reviewed-by: Axel Spoerl --- tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index 9b02b0e80da..f5315c06bf2 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -3374,6 +3374,12 @@ void tst_QTreeView::styleOptionViewItem() view.setRowHidden(3, par1->index(), true); view.setColumnHidden(1, true); + view.header()->setMinimumSectionSize(10); + // make sure that all columns are drawn in the view by using a very small section size + for (int i = 0; i < view.header()->count(); ++i) + view.header()->resizeSection(i, 20); + view.setMinimumWidth(view.header()->count() * 20); + const int visibleColumns = 4; const int modelColumns = 5;