-
Notifications
You must be signed in to change notification settings - Fork 1
/
graphicsplaneview.cpp
62 lines (50 loc) · 1.46 KB
/
graphicsplaneview.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* Copyright (C) 2018 Microchip Technology Inc. All rights reserved.
* Joshua Henderson <[email protected]>
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "graphicsplaneview.h"
#include <QApplication>
#include <QPaintEvent>
#include <QDebug>
#include <QGraphicsItem>
#include <QGraphicsSceneMouseEvent>
GraphicsPlaneView::GraphicsPlaneView(QGraphicsScene *scene)
: QGraphicsView(scene)
{
setAttribute(Qt::WA_NoSystemBackground);
}
void GraphicsPlaneView::paintEvent(QPaintEvent * event)
{
qDebug() << "GraphicsPlaneView::paintEvent " << event->region().boundingRect();
QGraphicsView::paintEvent(event);
}
bool GraphicsPlaneView::eventFilter(QObject* object, QEvent* event)
{
qDebug() << "GraphicsPlaneView::eventFilter " << event;
if (event->type() == QEvent::UpdateRequest) { return true; }
if (event->type() == QEvent::Paint) { return true; }
Q_UNUSED(object);
return false;
}
bool GraphicsPlaneView::event(QEvent *event)
{
qDebug() << "GraphicsPlaneView::event " << event->type();
if (event->type() == QEvent::Paint) { return true; }
return QGraphicsView::event(event);
}
void GraphicsPlaneView::mousePressEvent(QMouseEvent *event)
{
QGraphicsView::mousePressEvent(event);
if (!event->isAccepted())
emit clicked();
}
void GraphicsPlaneView::keyPressEvent(QKeyEvent* k)
{
if(k->key() == 48){
QApplication::instance()->exit();
}
}
GraphicsPlaneView::~GraphicsPlaneView()
{}