Skip to content Skip to sidebar Skip to footer

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:

  1. Accept dragDrop events with accept() and acceptProposedAction() methods
  2. Re-implement the dragEnterEventdragMoveEvent and dropEvent.
  3. 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"