Results 1 to 4 of 4

Thread: dragNdrop between QTreeWidget and QTextEdit

  1. #1
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    84
    Thanks
    7
    Thanked 2 Times in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default dragNdrop between QTreeWidget and QTextEdit

    hi,

    how can i drag an item from a qtreewidget to a qtextedit?
    dragging is enabled to the qtreewidget, but it's not possible to
    drop it (insert the text of the item) on the qtextedit.

    best regards,
    jh

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: dragNdrop between QTreeWidget and QTextEdit

    You should reimplement events in the text edit object to handle the drop. If the drag is a textual one (it has mime text/plain), it should work out of the box, provided that you have told the text edit to accept drops.

  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    84
    Thanks
    7
    Thanked 2 Times in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: dragNdrop between QTreeWidget and QTextEdit

    the text should be copied from the qtreewidget to the
    qtextedit. so how can i provide a text/plain mime object to be
    dragged from the treeview?

    jh

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: dragNdrop between QTreeWidget and QTextEdit

    There is no easy way of doing that for a tree widget. You should use a tree view with a custom model, where you could implement the drag mime easily. In your case it should be easier to reimplement dragEnterEvent and dropEvent for the text edit to handle the drag from a tree widget (just check what mime it uses, for example by using the "droptarget" example from Qt bundle).

  5. The following user says thank you to wysota for this useful post:

    jh (18th September 2006)

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.