Results 1 to 2 of 2

Thread: Drag into a QDeclarativeView

  1. #1
    Join Date
    Dec 2010
    Location
    Israel
    Posts
    90
    Thanks
    59
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Drag into a QDeclarativeView

    I have a QDeclarativeView to display my QML. I want to implement an interaction with my existing widgets, mainly to drag an item from a QTreeView and drop it onto the QDeclarativeView - I want to catch just the drop action and then based on the mime data decide what to do in my QML.

    Currently I tried to setAcceptDrops(true) on my QDeclarativeView but still, when I try to drag an item on top of it I have the mouse cursor saying no drop is allowed.

    I couldn't find an example for this online. Can anyone help out?

    Qt Code:
    1. // header
    2. QDeclarativeView *mView;
    3. QDeclarativeEngine *mEngine;
    4. QDeclarativeContext *mContext;
    5.  
    6. // cpp
    7. mView = new QDeclarativeView(this);
    8. mEngine = mView->engine();
    9. mContext = mEngine->rootContext();
    10. mView->setAcceptDrops(true);
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Dec 2010
    Location
    Israel
    Posts
    90
    Thanks
    59
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Drag into a QDeclarativeView

    Solution: as presented by mbrasser from the Qt Nokia Developer forums:

    The qmlviewer application implements drag-and-drop for the view; if you’d like to refer to the source it is implemented in tools/qml/qmlruntime.cpp.
    I used the implementation from there and seems like it's working.

Similar Threads

  1. Replies: 0
    Last Post: 3rd September 2011, 19:04
  2. Resize QDeclarativeView
    By Globulus in forum Qt Programming
    Replies: 3
    Last Post: 29th August 2011, 18:31
  3. Replies: 2
    Last Post: 16th July 2011, 13:39
  4. Using QDeclarativeView::Show()
    By proj_symbian in forum Qt Quick
    Replies: 17
    Last Post: 30th May 2011, 20:26
  5. Replies: 2
    Last Post: 9th May 2011, 03:04

Tags for this Thread

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.