Pyqt - Add Drag & Drop To Widget
I have a class that inherits from QWidget : from PyQt5.QtWidgets import * class Widget(QWidget): def __init__(self, layoutname: str, width: int, height: int ) -> None:
Solution 1:
I'm not sure if it answers you exactly what you want, but I had some problems before with dragDrop and maybe this question and answer that I spent a really long time can help you out here.
Summarizing, the main reasoning would be:
- Accept dragDrop events with
accept()
andacceptProposedAction()
methods - Re-implement the
dragEnterEvent
dragMoveEvent
anddropEvent
. - Inside these methods you should do what you want. For example call your droppedR methods inside the
dropEvent
methods.
It's up to you the logic you want to apply in each of the events.
Post a Comment for "Pyqt - Add Drag & Drop To Widget"