Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.4.1
-
None
-
Linux 3.19.2
-
937ded010b09250c6ab9a57917f2e430fb5875f5
Description
Hello, I have a problem with a QListView in IconMode using a grid layout.
When displayed for the first time, everything works like a charm (http://hpics.li/afafe3d), but if the underlying model updates it's content (using signal dataChanged), the updated items don't respect the grid size policy (http://hpics.li/035dcbf). Using model reset, the layout keeps it's integrity (but it messes up the selection model).
Is this a bug or am I doing something wrong ?
QListView initialization:
//... ui -> listView -> setMovement(QListView::Static); ui -> listView -> setResizeMode(QListView::Adjust); ui -> listView -> setViewMode(QListView::IconMode); ui -> listView -> setGridSize( QSize(150, 100)); ui -> listView -> setWrapping(true); ui -> listView -> setWordWrap(true); ui -> listView -> setMinimumHeight(100); //...
Use dataChanged in model, breaks the grid layout:
//... int index = storageUnits.indexOf(unit); if(index >= 0) { QModelIndex idx = createIndex(index, 0); emit dataChanged(idx, idx); } }
Use reset in model, layout OK but impact other features of the app:
//...
beginResetModel();
endResetModel();
Please find attached a small example illustrating this behaviour (based on QStringListModel for the sake of conciseness)