Qgraphicsitem drag and drop
i have a problem with qt i want to drag an image and use of Qgraphicspixmapitem and dragenterevent but it doesnt appear in the console ? but other function like hoverEnterEvent work corectly??? hear is the code: please help?
:
Code:
#ifndef BUTTON_H
#define BUTTON_H
#include <QGraphicsObject>
#include <QGraphicsPixmapItem>
#include <QPixmap>
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsSceneHoverEvent>
#include <QDrag>
{
public:
button(){setAcceptHoverEvents(1);
setAcceptDrops(true);}
void dragenterEvent(QGraphicsSceneDragDropEvent *event){
event->setAccepted(1);
qDebug("drag");
}
void dropEvent(QGraphicsSceneDragDropEvent *event){
qDebug("drop");
}
// do something
// this->setPos(this->x()+10,this->y()+10);
qDebug("k");
}
};
#endif // BUTTON_H
Re: Qgraphicsitem drag and drop
There is a difference between dragenterEvent and dragEnterEvent.
Qgraphicsitem drag and drop
hi everyone
can anybody give me a simple example that i can drag and drop QGraphicsItem by using of :
void dragEnterEvent(QGraphicsSceneDragDropEvent *event)
very thanks.