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:
"""
Constructor, pass 0 to width and/or height if you want them to be defaults given at runtime
:param layoutname: Layout, a Layout object will be built according to the class name passed
:param width: int, width of the widget
:param height: int, height of the widget
"""
super(QWidget, self).__init__()
if width != 0:
self.setFixedWidth(width)
if height != 0:
self.setFixedHeight(height)
layout = layoutname()
self.setLayout(layout)
def addChild(self, child: object)-> None:
"""
Adds child as a child to the widget
:param child: Widget, the child you want to add to the current widget
"""
self.layout().addWidget(child)
def droppedR(self):
print("DROPPED")
I want to add the following feature: When something is dropped (let's say a file) on the widget, I want to call droppedR(). How can I do that ?