Dnd moveAction QabstractItemModel



  • 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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.