Results 1 to 4 of 4

Thread: Drag and Drop with Qt Quick and QWidgets

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

    Default Drag and Drop with Qt Quick and QWidgets

    I’m upgrading my application from Qt 4.8 to Qt 5.1, with Qt Quick 2.1.

    I used to display a QML view in my mostly widget based application, on top of QDeclarativeView.

    Originally I subclassed QDeclarativeView to add drag/drop functionality, so I could drop on top of the view and respond to it in my code.

    To get the new QQuickView into a QWidget, I see I have the QWidget::createWindowContainer() method.

    However, I get a specific QWidget* from this method and I'm not sure how to go about getting the drop functionality I require for my application.

    Can anyone please advise here?

  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: Drag and Drop with Qt Quick and QWidgets

    I don't think it is possible to give you advice without understanding first how you implemented drag and drop.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    Default Re: Drag and Drop with Qt Quick and QWidgets

    Thanks for responding wysota,

    You mean in my previous solution?

    The QDeclarativeView was a subclass of QWidget, so I subclassed it, put in setAcceptDrops(true) in the constructor and implemented the methods for the drag and drop events. Actually my "drop" just emitted a signal, and the manipulation of the QML was done separately - but with the current system I can't find how to even get these events handled. I mean, I just want to have a point when I know that something is being dragged onto the widget the ends up displaying the QQuickView, so I can handle that.

    Is this any more clear now?

  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: Drag and Drop with Qt Quick and QWidgets

    createWindowContainer() returns a QWidget instance. You can install an event filter on it and try to intercept d&d events there. If it doesn't work, you can try intercepting events by subclassing the window class and reimplementing event(). If that doesn't work as well then... I suggest you file a bug report
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 0
    Last Post: 7th January 2012, 16:20
  2. Drag and Drop file into Qt Quick window
    By marwooj in forum Qt Quick
    Replies: 0
    Last Post: 23rd June 2011, 05:04
  3. Replies: 2
    Last Post: 13th October 2010, 22:51
  4. Replies: 3
    Last Post: 10th June 2010, 16:13
  5. Replies: 0
    Last Post: 4th May 2010, 11:24

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.