Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Pyside6: Drop file in QTextEdit doesn't work anymore
QtWS25 Last Chance

Pyside6: Drop file in QTextEdit doesn't work anymore

Scheduled Pinned Locked Moved Unsolved Qt for Python
5 Posts 2 Posters 643 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hizoka
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Which exact version of PySide6 ?
      On which platform ?

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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • H Offline
        H Offline
        hizoka
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          System pip ?
          Virtualenv ?
          Conda ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • H Offline
            H Offline
            hizoka
            wrote on last edited by
            #5

            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)
            
            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved