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

前端 未结 2 1796
野性不改
野性不改 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.

提交回复
热议问题