Results 1 to 2 of 2

Thread: Empty mimedata of dynamic qml object

  1. #1
    Join Date
    Feb 2010
    Location
    Russia, Omsk
    Posts
    28
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    4

    Default Empty mimedata of dynamic qml object

    I have a treeview from which I drag items to a drop area by creating draggable items dynamically. Everything works except I cannot pass mimedata
    Qt Code:
    1. function createItem(parentItem)
    2. {
    3. if (itemComponent.status === Component.Ready && draggedItem == null)
    4. {
    5. draggedItem = itemComponent.createObject(
    6. parentItem,
    7. {
    8. "x": positionInParent.x,
    9. "y": positionInParent.y,
    10. "baseColor":Qt.lighter("red", 1.5),
    11. "copyable":false,
    12. visible: true
    13. }
    14. );
    15.  
    16. draggedItem.Drag.mimeData = { "text/plain": "Hello!" };
    17. draggedItem.Drag.supportedActions = Qt.CopyAction;
    18. draggedItem.Drag.dragType = Drag.Automatic;
    19. draggedItem.Drag.start();
    20. }
    21. else if (itemComponent.status === Component.Error) {
    22. draggedItem = null;
    23. console.log("error creating component");
    24. console.log(itemComponent.errorString());
    25. }
    26. }
    To copy to clipboard, switch view to plain text mode 
    when I try to get the mime data from drop event (drop.text field) it is empty.
    Qt Code:
    1. DropArea
    2. {
    3. height:parent.height
    4. width:parent.width
    5. onDropped: {
    6. drop.acceptProposedAction()
    7. var txt = drop.text; // Empty!!!
    8. console.log("dropped into dest")
    9. }
    10. onEntered: {
    11. console.log("entered dest")
    12. }
    13. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Empty mimedata of dynamic qml object

    Hmm, the documentation says the type of "mimeData" is "stringlist", have you tried something like
    Qt Code:
    1. mimeData = [ "hello" ];
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

Similar Threads

  1. Replies: 0
    Last Post: 6th September 2013, 13:05
  2. dynamic object id
    By jovin in forum Qt Quick
    Replies: 2
    Last Post: 1st May 2012, 02:19
  3. How to generate dynamic object
    By tuxit in forum Qt Quick
    Replies: 0
    Last Post: 17th August 2011, 13:49
  4. How to drag dynamic object in Qml?
    By Franziss in forum Newbie
    Replies: 0
    Last Post: 28th May 2011, 17:07
  5. Empty QSqlTableModel object
    By gemidjy in forum Qt Programming
    Replies: 2
    Last Post: 14th March 2008, 11:42

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
  •  
Qt is a trademark of The Qt Company.