[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    QGraphicsView, QGraphicsScene Drag and drop
From:       "=?ISO-8859-1?Q?Alexis_M=E9nard?=" <darktears31 () gmail ! com>
Date:       2008-04-23 13:18:27
Message-ID: 81941aea0804230618r6851ab30w185f31ff5a196c6b () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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.


[Attachment #5 (text/html)]

Hello,<br><br><br>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.<br><br>It was impossible in Qt directly in the scene, you must have \
an item that accept drop events (set with<span style="color: rgb(0, 79, 175);"> \
</span><span style="color: rgb(0, 0, 0);">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 &quot;cover&quot; all the \
scene, then we can drag and drop music into the playlist (<a \
href="http://websvn.kde.org/trunk/extragear/multimedia/amarok/src/playlist/PlaylistDro \
pVis.cpp?revision=760687&amp;view=markup">http://websvn.kde.org/trunk/extragear/multim \
edia/amarok/src/playlist/PlaylistDropVis.cpp?revision=760687&amp;view=markup</a>).<br>
 <br>I think it&#39;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 </span><span \
style="color: rgb(0, 0, 0);"> method </span><span style="color: rgb(0, 0, 0);">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.<br> <br>My question is why? Is \
there a technical reason behind this choice? Why acceptDrops method exists on \
QGraphicsItem, on QGraphicsView but not in QGraphicsScene?<br><br>I have find a \
solution to &quot;bypass&quot; this problem by overloading the dragMoveEvent method \
of the scene and accept the event after calling the parent method. It works perfectly \
but it&#39;s not really good. Another solution?<br> <br>void \
QScene::dragMoveEvent(QGraphicsSceneDragDropEvent *event)<br>{<br>&nbsp;&nbsp;&nbsp; \
QGraphicsScene::dragMoveEvent(event);<br>&nbsp;&nbsp;&nbsp; \
event-&gt;accept();<br>}<br><br>Perhaps amarok team will be interessted by \
this.<br></span>



>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic