Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-94226

QListView - broken drag-n-drop items movement

    XMLWordPrintable

Details

    • Windows
    • 14e09ada69fc3f1b09a8ad8228c3b8ebb542b220 (qt/qtbase/dev) 6809ee8f3e52187807807fd4ff7f59ec90a8e234 (qt/tqtc-qtbase/5.15) 04cc12e26f8ee356ae666f50a85f0db3804d9c8a (qt/qtbase/6.1)

    Description

      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)    , "cancel"));
      
          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 x64) 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 items have become undraggable and unmovable with the same code. The same is true for Qt 6.1.0 - the newest version of Qt.

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            vhilshei Volker Hilsheimer
            alexnevskiy Alex Nevskiy
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes