Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
6.4.0 Beta2
-
None
Description
An empty view which contains an QStandardModel and is setted a delegate to paint items.
The view is setted wrapping to true. // this is necessary
And the Item's width is little bigger than viewport's width minus double spacing(spacing is 40 and the item's width is width - 79)
Then the spacing of the top item gets to 80(double spacing)
I'm not sure if this is a BUG, can be reproduce in multi versions of Qt.
I tested it in Qt 6.4.0
—
this is the main code.
//代码占位符 MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); // there is only a QListView in the UI file. QStandardItemModel *model = new QStandardItemModel(this); model->appendRow(new QStandardItem("hello Qt")); model->appendRow(new QStandardItem("hello Dtk")); ui->listView->setModel(model); ui->listView->setSpacing(40); ui->listView->setFlow(QListView::LeftToRight); ui->listView->setItemDelegate(new Delegate(ui->listView)); ui->listView->setResizeMode(QListView::Adjust); ui->listView->setWrapping(true); // this is necessary and will not be reproduce if it's not setted. }
---
this is the execution
Red rectangle is the item, green line is the width of the Item, and black line is the spacing.
if the item's width is less than viewport's width - 2 * spacing, or view->setWrapping(false) is setted, the top spacing is correct.