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 and Drop of QListView Items
Qt 6.11 is out! See what's new in the release blog

Drag and Drop of QListView Items

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 5.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.
  • M Offline
    M Offline
    Macro
    wrote on last edited by
    #1

    Hi..
    I have a ListView and a Widget. In ListView i had added few items using QStandardItem. Now i want to Drag and Drop the ListView Items to the Widget . I can drag and drop my ListView Items inside the ListView by using

    @listView.setAcceptDrops(true);
    listView.setDragEnabled(true);
    listView.setDragDropMode(QAbstractItemView::InternalMove); @

    But i want to Drag and Drop the Items to the Widget. so i tried to override the following methods.

    @void dropEvent(QDropEvent *);
    void dragMoveEvent(QDragMoveEvent *);
    void dragEnterEvent(QDragEnterEvent *);
    void mousePressEvent(QMouseEvent *);
    void startDrag(Qt::DropActions supportedActions);@

    After trying this i can able to drag my items to the widget but i can't drop my items on the widget.. don't know where i did the mistake. please help me to solve this..

    Thanks & Regards...

    1 Reply Last reply
    0
    • H Offline
      H Offline
      hpollak
      wrote on last edited by
      #2

      There are some real good d&d-examples in the doc-area.
      I think there should be a solution to your problem.

      "examples-draganddrop":http://qt-project.org/doc/qt-4.8/examples-draganddrop.html

      I think the example DragableText will best fit.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Macro
        wrote on last edited by
        #3

        Yeah its a very good example. Thanks for your reply. But the thing is, there they r using the QLabel, hence they can easily type cast it and get the position of the Label. but here am using a standard item model... i can type cast my standard item model but i can't get the posiiton. In order to get the position, i have to use a QModelIndex. Using QModelIndex also i can't get the indexAt(event->pos()). that is not working. . :( what should i do now... plz help me...!!!

        Thanks & Regards...

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dscyw
          wrote on last edited by
          #4

          Same problem bothered me.

          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