Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Pyside6: Drop file in QTextEdit doesn't work anymore



  • Hello,

    I guess I founded a bug :

    #!/bin/python3
    
    from PySide6.QtWidgets import QApplication, QPlainTextEdit, QMainWindow, QTextEdit
    
    class QPlainTextEditCustom(QTextEdit):
        def __init__(self, parent):
            super().__init__(parent)
            self.setAcceptDrops(True)
    
        def dragEnterEvent(self, event):
            print("QPlainTextEditCustom dragEnterEvent")
            event.acceptProposedAction()
    
        def dropEvent(self, event):
            print("QPlainTextEditCustom dropEvent")
            event.acceptProposedAction()
    
    class MainWindow(QMainWindow):
        def __init__(self):
            super().__init__()
            self.setAcceptDrops(True)
            self.MoviesSearchedTextEdit = QPlainTextEditCustom(self)
    
    if __name__ == '__main__':
        qApp = QApplication()
        MainWindow = MainWindow()
        MainWindow.show()
        qApp.exec()
    

    Impossible to drop a file in the QTextEdit, Drag never accepted.
    Same problem with QPlainTextEdit.
    I tried with event.accept also...

    This code work with PySide2 or PyQt5.

    It's work with another widget like QPushButton or QLineEdit or QDIal...

    Any idea ?

    Thank you.


  • Lifetime Qt Champion

    Hi,

    Which exact version of PySide6 ?
    On which platform ?

    Just tested on Linux with 6.1.2 installed with pip and your code worked.



  • Qt : 6.1.3 and now 6.2.0
    PySide : 6.1.3 and now 6.2.0
    PySide installed with pip.
    KDE neon User Edition 5.22 (Ubuntu 20.04)

    It's OK with Qt 5.15.3


  • Lifetime Qt Champion

    System pip ?
    Virtualenv ?
    Conda ?



  • I just used :

    pip3 install pyside6
    
    pip3 --version
    pip 21.2.4 from /home/hizoka/.local/lib/python3.8/site-packages/pip (python 3.8)
    

Log in to reply