[Python] QVideoWidget not reciving dropEvent (strange behavior)

Discussão em 'Python' iniciado por Stack, Agosto 6, 2025.

  1. Stack

    Stack Membro Participativo

    I want to play a media on dropEvent of a QVideoWidget. I know the playing part, my problem is QVideoWidget not receiving dropEvent like other widgets. I'm wonder this is a bug or I am missing something.

    Everything is ok and all three events getting called:

    import sys
    from PySide6.QtCore import QSize
    from PySide6.QtMultimediaWidgets import QVideoWidget
    from PySide6.QtWidgets import QApplication, QWidget

    class MyWidget(QWidget):
    def __init__(self,*args):
    super().__init__(*args)

    self.setAcceptDrops(True)
    self.setMinimumSize(QSize(600,400))

    def dragEnterEvent(self, event):
    print(event)
    event.accept()

    def dragMoveEvent(self, event):
    print(event)
    event.accept()

    def dropEvent(self, event):
    print(event)

    if __name__ == "__main__":
    app = QApplication([])
    widget = MyWidget()
    widget.show()
    sys.exit(app.exec())


    But when I use same code with a QVideoWidget , dropEvent not getting called:

    import sys
    from PySide6.QtCore import QSize
    from PySide6.QtMultimediaWidgets import QVideoWidget
    from PySide6.QtWidgets import QApplication, QWidget

    class MyWidget(QVideoWidget):
    def __init__(self,*args):
    super().__init__(*args)

    self.setAcceptDrops(True)
    self.setMinimumSize(QSize(600,400))

    def dragEnterEvent(self, event):
    print(event)
    event.accept()

    def dragMoveEvent(self, event):
    print(event)
    event.accept()

    def dropEvent(self, event):
    print(event)

    if __name__ == "__main__":
    app = QApplication([])
    widget = MyWidget()
    widget.show()
    sys.exit(app.exec())


    P.S : I don't know why but in the last code dropEvent works on title bar! I can upload a GIF if needed.

    Continue reading...

Compartilhe esta Página