Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Drag'n'Drop with QListView
Qt 6.11 is out! See what's new in the release blog

Drag'n'Drop with QListView

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kukuyok
    wrote on last edited by
    #1

    Hello everyone! I have created 3 my own classes inheriting from QAbstractListModel, QListView and QItemDelegate which work together like MVC. I'm creating browser like view and I need to use a child of QAbstractItemView like a Drag'n'Drop widget, interacting with another applications. I've achieved realization of drag operation, but I'm not able to launch drop operation. What I have done:

    1. Reimplemented methods of QAbstractListModel:
    1. rowCount()
    2. headerData()
    3. data()
    4. flags()
    5. setData()
    6. mimeTypes()
    7. mimeData()
    8. dropMimeData()
    9. supportedDropActions()
    1. For a child of QListView I've implemented next settings:
    1. setAcceptDrops(true);
    2. setDragEnabled(true);
    3. setDragDropMode(QAbstractItemView::InternalMove);
    4. setDropIndicatorShown(true);
    5. setSelectionMode(QAbstractItemView::SingleSelection);
    6. setDragDropMode(QAbstractItemView::DragDrop);

    Gave myself up to despair, I've reimplemented dragEnterEvent() for a child of QListView too (with use after QListView::dragEnterEvent(e)). It shows that MIME object comes to my widget and has correctly data. But no one call to drop-methods of a child of QAbstractListModel occurs.

    Does anybody see a foolish thing in my actions?)

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      You might need to (re)implement draMoveEvent() and dropEvent() too. Depending on your use case, dragLeaveEvent() too.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved