I'm making some project for university (checkers, if exactly).
I'm doing it with help of QtDesigner and in .ui file I have QGraphicsView that is my scene.
The "ItemIsMovable" flag is set, of course.
And I need to implement drag and drop of checker.
I'm trying to do it with QGraphicsSceneDragDropEvent. So I have two classes:
One that describes "Pawn"
class Pawn : public QObject, public QGraphicsEllipseItem {
Q_OBJECT
private:
QBrush kolor;
public:
Pawn(int x, int y, int rozmiar);
void dragEnterEvent(QGraphicsSceneDragDropEvent *event) override;
void dragLeaveEvent(QGraphicsSceneDragDropEvent *event) override;
void dropEvent(QGraphicsSceneDragDropEvent *event) override;
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
};
And second, that describes one tile in board
class Tile : public QObject, public QGraphicsRectItem {
Q_OBJECT
private:
int x,y,row,col;
QBrush color;
Pawn *pawn;
public:
Tile(QBrush color, int x, int y, int col, int row);
bool isPawnSet();
void setPawn(Pawn *pawn);
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
};
So, when I drag and drop my pawn. No one of the Event methods is running(I have some QDebugs in them, so I know that nothing happens). I don't really know why. Because *event is passed as argument.
My question is, how to implement it in correct way? If you need more code, I will share it.