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. Drop into specific item of WidgetList
Qt 6.11 is out! See what's new in the release blog

Drop into specific item of WidgetList

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.1k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hello,

    I got a WidgetList, which contains some items. Now I want to drag some items onto those items in the WidgetList, like when I drop music into an iTunes playlist. I know how to drop data into a WidgetList, but how do I determinate on which item I dropped the data? After that I will do some further processing.
    Thanks for your help :D

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Sam
      wrote on last edited by
      #2

      If you are using a QListView then you can access the index of the item while dropping to the list based on event position. You need to subclass your QListView and override the following functions based on your requirement :-

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

      In the dropEvent you can get the index using :-

      @QModelIndex index = indexAt(event->pos());@

      You can also set the mimeData inorder to differentiate between multiple lists.

      I have worked on few cases with drag & drop on listView, if you need any help feel free to ask.

      Thanks.

      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