How to decode “application/x-qabstractitemmodeldatalist” in Qt for drag and drop?

前端 未结 3 1504
醉梦人生
醉梦人生 2020-12-10 03:48

I\'ve created a child class of QTreeWidget that I want to be able to drag items from another tree widget too (I want to handle the insertion myself though), as well as from

3条回答
  •  难免孤独
    2020-12-10 04:13

    Looks like you can use QStandardItemModel to decode the data and get an item back out. Don't know if this is the best way to do it though:

      model = QStandardItemModel()
      model.dropMimeData(event.mimeData(), Qt.CopyAction, 0,0, QModelIndex())
    

    Then you can use the item() method from model to retrieve the item and handle it however you want.

提交回复
热议问题