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?
:
#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
#ifndef BUTTON_H
#define BUTTON_H
#include <QGraphicsObject>
#include <QGraphicsPixmapItem>
#include <QPixmap>
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsSceneHoverEvent>
#include <QDrag>
class button : public QGraphicsPixmapItem
{
public:
button(const QPixmap &);
button(){setAcceptHoverEvents(1);
setAcceptDrops(true);}
void changepic( QPixmap,int ,int);
void mousePressEvent(QGraphicsSceneMouseEvent*event);
void dragenterEvent(QGraphicsSceneDragDropEvent *event){
event->setAccepted(1);
qDebug("drag");
}
void dropEvent(QGraphicsSceneDragDropEvent *event){
qDebug("drop");
}
void hoverEnterEvent(QGraphicsSceneHoverEvent *event){
// do something
// this->setPos(this->x()+10,this->y()+10);
qDebug("k");
QGraphicsItem::hoverMoveEvent(event);
}
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
};
#endif // BUTTON_H
To copy to clipboard, switch view to plain text mode
Bookmarks