Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. Dnd moveAction QabstractItemModel

Dnd moveAction QabstractItemModel

Scheduled Pinned Locked Moved Language Bindings
1 Posts 1 Posters 1.2k 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.
  • Y Offline
    Y Offline
    youmcheck
    wrote on last edited by
    #1

    Hi,
    I ve got a QListView and a QabstractItemModel,
    my Qlistview accept drap n drop and i can drop item from other widget,
    i force internal dnd to be moveaction only, so my QListView class is :

    @class TimelineListView(QtGui.QListView):
    def init(self,parent=None):
    super(TimelineListView,self).init(parent)
    self.setDropIndicatorShown(True)
    self.setDragDropMode(QtGui.QAbstractItemView.DragDrop)
    def dragEnterEvent(self,event):
    if event.source()==self:
    event.setDropAction(Qt.MoveAction)
    event.accept()
    else:
    event.acceptProposedAction()
    def dragMoveEvent(self,event):
    if event.source()==self:
    event.setDropAction(Qt.MoveAction)
    event.accept()@

    and i modify my dropMimeData to catch moveAction:
    @def dropMimeData(self,data,action,row,column,parent=QtCore.QModelIndex()):
    if action== Qt.IgnoreAction:
    return True
    if action == Qt.DropAction.MoveAction:
    if data.hasFormat("cdp/sequences"):
    encodedData=data.data("cdp/sequences")
    tmp=pickle.loads(encodedData)
    self.insertRowsSpec(parent.row(),1,tmp)
    #self.removeRows(position, row, parent) # <<<< HERE I WOULD LIKE TO DELETE SOURCE ITEM
    return True
    if action == Qt.DropAction.CopyAction:
    ....
    @

    but How Can i get the source index of the dropped index to delete it?
    I m not sure if it s the good way to do internal move?

    thanks for any advice.

    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