qtdrag-and-dropqwebkit

Qt can I drag and drop from widget to Qwebkit?


I'm developing simple HTML editor and I like to be able to drag and drop from a button that for example represent HTML text line and in the Qwebkit the HTML text line will be created does Qt support such action?

How should I approach such thing?


Solution

  • I believe it does, yes.

    What you need to do is set the mime type of your drag event. See here for details. Then on the webkit side, you can read the drops mime type to see what it was.

    You can then try one of the following approaches:

    1. Subclassing QWebView to implement dragEnterEvent and dropEvent. You can use event->pos() in the dropEvent to get the position where the drop occured.
    2. Implementing the drop in javascript within your page, eg setting up an event listener for drops or however its done (I've never tried this).