Unsolved QListView stop working on new Qt versions
-
I have the next code
#include <QFont> #include <QApplication> #include <QListView> #include <QStandardItemModel> class MyModel : public QStandardItemModel { public: Qt::ItemFlags flags(const QModelIndex &index) const override { Q_UNUSED(index); return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled; } }; //------------------------------------------------------------------------------ int main(int argc, char *argv[]) { QApplication a(argc, argv); a.setFont({"Verdana", 16}); MyModel model; auto style = a.style(); model.appendRow(new QStandardItem(style->standardIcon(QStyle::SP_DialogCancelButton), "cancel")); model.appendRow(new QStandardItem(style->standardIcon(QStyle::SP_FileDialogInfoView), "info")); model.appendRow(new QStandardItem(style->standardIcon(QStyle::SP_DialogOpenButton), "open")); model.appendRow(new QStandardItem(style->standardIcon(QStyle::SP_DialogSaveButton), "save")); model.appendRow(new QStandardItem(style->standardIcon(QStyle::SP_DialogOkButton), "ok")); QListView list; list.show(); list.resize(700, 500); list.setModel(&model); list.setIconSize({64, 64}); list.setViewMode(QListView::IconMode); list.setWrapping(false); list.setResizeMode(QListView::Fixed); list.setMovement(QListView::Snap); list.setGridSize({128, 128}); list.setSelectionBehavior(QAbstractItemView::SelectItems); list.setSelectionMode(QAbstractItemView::ExtendedSelection); list.setDragDropMode(QListView::DragDrop); list.setAcceptDrops(true); list.setDefaultDropAction(Qt::MoveAction); list.setDragDropOverwriteMode(false); list.showDropIndicator(); return a.exec(); }
In Qt 5.13.2 (MinGW) it works very well. I can move items in list similiarly like icons on the OS Windows desktop with snapping to grid. But in Qt 5.15.2 (edited) items have become undraggable and unmovable with the same code. The same is true for Qt 6.1.0 - the newest version of Qt. Was there some changes happened in QListView behaviour?
-
Hi,
Can you check with a version more recent if 5.12 ? If memory serves well they should be around .12.
Do you have the same issue with the latest 5.15 ?
-
@SGaist Hello. I'm sorrow, there's a typo in this moment. I meant not 5.12.2 version, but 5.15.2 - more later version than 5.13.2.
-
With Qt5.15.0 (opensuse leap 15.2) I can freely place the icons, with 5.15.2dev (latest free git source) I can reproduce the issue. Also reproducible with 6.0.3. Maybe I will find some time to investigate further. In the meantime please fill a bug report and post a link here -> bugreports.qt.io
-
@Christian-Ehrlicher
Ok. Thank you.
The link to issue report https://bugreports.qt.io/browse/QTBUG-94226