I am getting error at keyEvent while implementing snapping. The error is as follows :
error: invalid use of incomplete type 'class QKeyEvent'
switch(event->key())
My code to Key event is as follows :
void Snap::keyPressEvent(QKeyEvent* event)
{
switch(event->key())
{
case Qt::Key_Left:
moveBy(-gridSize, 0);
break;
case Qt::Key_Right:
moveBy(gridSize, 0);
break;
case Qt::Key_Up:
moveBy(0, -gridSize);
break;
case Qt::Key_Down:
moveBy(0, gridSize);
break;
default:
QGraphicsItem::keyPressEvent(event);
}
}
Please help me out to solve it.
You should include
QKeyEvent
class :