Results 1 to 2 of 2

Thread: Drag and drop problem with Qt 4.8.6, Pyside 1.2.2 and Python 2.7

  1. #1
    Join Date
    Oct 2014
    Posts
    2
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Drag and drop problem with Qt 4.8.6, Pyside 1.2.2 and Python 2.7

    Hello,

    I have a QWidget that contains a QListWidget and a QTextEdit (each reimplemented).
    I want to have the following feature and behaviour :
    - when an item from the QListWidget is selected then dragged and dropped to the QTextEdit, the item is inserted at the cursor position.
    - when a text from the QTextEdit is selected then dragged and dropped to the same QTextEdit, the text is moved at the cursor position.

    For each drag/dropEvent, I have the main code (dragEnterEvent example) :
    def dragEnterEvent(self, event):
    print "MyQTextEdit.dragEnterEvent()", event
    if isinstance(event.source(), QListWidget) :
    # Specific code when QListWidget
    ...
    event.accept()
    else :
    # Standard behaviour
    super(MyQTextEdit, self).dragEnterEvent(event)


    Unfortunately, when I call from Python and PySide the "event.source()" method, it provokes a SEGFAULT when I reuse the event object.
    I did the same program in pure C++/Qt and it works fine.

    Moreover, the following code works :
    def dragEnterEvent(self, event):
    print "MyQTextEdit.dragEnterEvent()", event
    super(MyQTextEdit, self).dragEnterEvent(event)

    But the following code crashes (notes the "event.source()" in print) :
    def dragEnterEvent(self, event):
    print "MyQTextEdit.dragEnterEvent()", event, event.source()
    super(MyQTextEdit, self).dragEnterEvent(event)


    I suppose there is a problem in Python or PySide library when using the "event.source()" function which returns a pointer from a volatile QWidget which seems persistent after in Python and which doesn't exist anymore when I reuse the event object in Qt.

    Thanks for your help.

    The code is in attachment.


    Added after 43 minutes:


    The C++ corresponding code that works fine in attachment.
    Attached Files Attached Files
    Last edited by Lovehina13; 2nd October 2014 at 11:29.

  2. #2
    Join Date
    Oct 2014
    Posts
    2
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Drag and drop problem with Qt 4.8.6, Pyside 1.2.2 and Python 2.7

    The Python code works if we use PyQt4 instead of PySide.
    I think I'll report this problem to the Qt development team.

Similar Threads

  1. problem about drag and drop tip
    By Raul in forum Qt Programming
    Replies: 2
    Last Post: 16th September 2011, 09:52
  2. boost python inside pyside
    By strattonbrazil in forum Qt Programming
    Replies: 0
    Last Post: 11th August 2011, 16:54
  3. Drag and Drop problem
    By ScoOteR in forum Qt Programming
    Replies: 16
    Last Post: 19th May 2010, 14:57
  4. Getting AbstractItemData from drag/drop in Python
    By Hookem in forum Qt Programming
    Replies: 2
    Last Post: 12th December 2008, 23:23
  5. Drag&Drop problem
    By m1k3l3 in forum Qt Programming
    Replies: 4
    Last Post: 26th September 2008, 12:07

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.