From kde-devel Wed Apr 23 13:18:27 2008 From: "=?ISO-8859-1?Q?Alexis_M=E9nard?=" Date: Wed, 23 Apr 2008 13:18:27 +0000 To: kde-devel Subject: QGraphicsView, QGraphicsScene Drag and drop Message-Id: <81941aea0804230618r6851ab30w185f31ff5a196c6b () mail ! gmail ! com> X-MARC-Message: https://marc.info/?l=kde-devel&m=120895678821473 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--===============1395542288==" --===============1395542288== Content-Type: multipart/alternative; boundary="----=_Part_18818_16167041.1208956707328" ------=_Part_18818_16167041.1208956707328 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello, Just a simple tip that i have find during a developpement. My first need was the possibility to drag and drop things into a QGraphicsScene from an another widget. It was impossible in Qt directly in the scene, you must have an item that accept drop events (set with setAcceptDrops), then you can drop on it. I have looking for in Amarok 2 code for their playlist (based on QGraphicsView) and they do the same that i explain, the have put an item that "cover" all the scene, then we can drag and drop music into the playlist ( http://websvn.kde.org/trunk/extragear/multimedia/amarok/src/playlist/PlaylistDropVis.cpp?revision=760687&view=markup ). I think it's annoying, because if the view is scale, move, rotate and so and we have to manage this background item to have a drag and drop area all in the view. I have looking for in Qt code, especially in drag move event method from QGraphicsScene class and i find a code that looking for an item that accept drop just under the mouse before accepting the drag/drop event. My question is why? Is there a technical reason behind this choice? Why acceptDrops method exists on QGraphicsItem, on QGraphicsView but not in QGraphicsScene? I have find a solution to "bypass" this problem by overloading the dragMoveEvent method of the scene and accept the event after calling the parent method. It works perfectly but it's not really good. Another solution? void QScene::dragMoveEvent(QGraphicsSceneDragDropEvent *event) { QGraphicsScene::dragMoveEvent(event); event->accept(); } Perhaps amarok team will be interessted by this. ------=_Part_18818_16167041.1208956707328 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello,


Just a simple tip that i have find during a developpement. My first need was the possibility to drag and drop things into a QGraphicsScene from an another widget.

It was impossible in Qt directly in the scene, you must have an item that accept drop events (set with setAcceptDrops), then you can drop on it. I have looking for in Amarok 2 code for their playlist (based on QGraphicsView) and they do the same that i explain, the have put an item that "cover" all the scene, then we can drag and drop music into the playlist (http://websvn.kde.org/trunk/extragear/multimedia/amarok/src/playlist/PlaylistDropVis.cpp?revision=760687&view=markup).

I think it's annoying, because if the view is scale, move, rotate and so and we have to manage this background item to have a drag and drop area all in the view. I have looking for in Qt code, especially in drag move event
method from QGraphicsScene class and i find a code that looking for an item that accept drop just under the mouse before accepting the drag/drop event.

My question is why? Is there a technical reason behind this choice? Why acceptDrops method exists on QGraphicsItem, on QGraphicsView but not in QGraphicsScene?

I have find a solution to "bypass" this problem by overloading the dragMoveEvent method of the scene and accept the event after calling the parent method. It works perfectly but it's not really good. Another solution?

void QScene::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
{
    QGraphicsScene::dragMoveEvent(event);
    event->accept();
}

Perhaps amarok team will be interessted by this.
------=_Part_18818_16167041.1208956707328-- --===============1395542288== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe << --===============1395542288==--