PDA

View Full Version : Implementing drag drop for multiple QGraphicsItem



SiddhantR
26th February 2014, 09:18
I am trying to implement a drag and drop for QGraphicItem. I am using the following method.

http://stackoverflow.com/questions/17216420/drag-and-drop-of-qgraphicsitem-between-two-pairs-of-qgraphicsscene-qgraphicsview


However I need two objects of the same QGraphicsItem in my scene. I add them in the constructor by keeping them static. I also check for validations in the mousemove of QGraphicsItem and start the drag.

GraphicsItemClass::mouseMove(QGraphicsSceneMouseEv ent *event)
{
if() //this = 1 static object created in GraphicsScene class
{

//code for starting drag similar to one in the link

}
else //The other static object created in Graphics Scene Class
{

//Same code.

}
}
I tried changing the name of the byteArray and Mime Data in both the cases but still the problem exists. When I drop the object in Scene if I drop one item the other item also moves its position relatively. Can some one give me a solution for this.

Thank You.