0

I somehow cannot access the class QGraphicsSceneMouseEvent. I don't get what the problem is.

The error occurs when I want to access the mouseEvent.

HEADER

#ifndef SCHAAKBORDUI_H
#define SCHAAKBORDUI_H

#include <QGraphicsScene>
#include "schaakbordvakjeui.h"


class QGraphicsSceneMouseEvent;

class SchaakbordUi : public QGraphicsScene {
public:
    SchaakbordUi();

private:
    bool vakjeGeselecteerd;
    schaakbordVakjeUi *geselecteerd = nullptr;

    void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);
};

#endif // SCHAAKBORDUI_H

SOURCE

#include "schaakbordui.h"

#define BREEDTE_BORD 8

SchaakbordUi::SchaakbordUi() {
    vakjeGeselecteerd = false;

    for (int i = 0; i < BREEDTE_BORD; i++) {
        for (int j = 0; j < BREEDTE_BORD; j++) {
            this->addItem(new schaakbordVakjeUi(i * 100, j * 100));
        }
    }
}

void SchaakbordUi::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) {
   if (mouseEvent->button == Qt::LeftButton);
}

Siebe Dreesen
  • 25
  • 1
  • 8

1 Answers1

2

You need to

#include <QGraphicsSceneMouseEvent>

for the type to be defined.

Do this in the implementation file when possible, not the header. There's no need to import more code broader than necessary.

Jesper Juhl
  • 30,449
  • 3
  • 47
  • 70