Drag and drop with Qt: Knowing target application on hover - is it possible?

前端 未结 2 1797
野性不改
野性不改 2021-02-18 13:43

I\'m currently exploring the possibilities of drag-and-drop from a Qt application, into an unknown target application. The question is whether it is possible for the Qt applicat

相关标签:
2条回答
  • 2021-02-18 14:04

    You can't really know which application is going to receive your drop. However, that doesn't prevent you from including different format of data in the buffer associated to the drag and drop. Class QMimeData provides the method setData, which takes mimeType as a first argument. You can put some data for a given mimetype, and some other for a different mimeType. It doesn't erase the first one. Custom mimeData are typically more useful for drops inside your application, but there are some relatively standard ones as : setText, setHtml, setUrls, setImageData, and setColorData.

    Typically, you can put both some text and some image in the drag at the same time, and the receiving application should take the one it needs.

    0 讨论(0)
  • 2021-02-18 14:14

    You can add several data types to your drag mime data. While creating dragable data you can put image and points data (with proper mime-type) and each application will decide what data it accepts and how to interpret it.

    For more details check https://doc.qt.io/qt-5/dnd.html#dragging

    0 讨论(0)
提交回复
热议问题