[Development] QtQuick: Drag pixmap

Mark Gaiser markg85 at gmail.com
Tue Jan 28 22:25:58 CET 2014


On Tue, Jan 28, 2014 at 8:28 PM, Alan Alpert <416365416c at gmail.com> wrote:
> On Wed, Jan 22, 2014 at 10:42 AM, Mark Gaiser <markg85 at gmail.com> wrote:
>> On Wed, Jan 22, 2014 at 12:11 AM, Fabien Castan <fabcastan at gmail.com> wrote:
>>> Hi,
>>>
>>> Qt 5.2 adds the possibility to use drag&drop from/to external applications.
>>> To allows to drag an item from QML to an external application, we can't
>>> simply set a target item, because we want to see this item ouside of the qml
>>> window.
>>> In Qt, we could set a pixmap on drag events:
>>> http://qt-project.org/doc/qt-4.8/qdrag.html#setPixmap
>>>
>>> I don't see something like that in QtQuick (Qt 5.2):
>>> http://qt-project.org/doc/qt-5/qml-qtquick-drag.html
>>>
>>> Is there a solution to do such thing in pure QML?
>>>
>>> Regards,
>>> Fabien
>>
>> While browsing through the code (qquickdrag.cpp) i found these two
>> commented lines:
>>     // TODO: how to handle drag image?
>>     // drag->setPixmap(iconPixmap);
>>
>> Along with that no more function for "setPixmap" that is exposed to QML.
>> That makes me fear that the setPixmap property is not there anymore.
>>
>> Odd, since it would be an API break which i can't really imagine from Qt.
>>
>> I hope someone else more knowledgeable in this area can chime in?
>
> Use of direct QPixmaps in QML is discouraged, because there's no real
> way to manage the memory of the pointer. If there were a QObject or
> QJSValue wrapper around QPixmap then a setPixmap could be added,
> similar to the setPixmap in QDrag (although not actually accepting a
> QPixmap type).
>
> So without a good solution handy, that part has been left "for later".

Alan, would it be possible to use a Image{...} item as "pixmap"?
Yes, right now it's not possible, but just as an idea for a workable
implementation.



More information about the Development mailing list