-
Notifications
You must be signed in to change notification settings - Fork 0
/
tabclass.cpp
75 lines (70 loc) · 2.14 KB
/
tabclass.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
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "tabclass.h"
TabClass::TabClass(QWidget *parent) : QWidget(parent)
{
mLayout = new QHBoxLayout();
this->setLayout(mLayout);
mScene = new QGraphicsScene();
// mScene = new DrawCrosses();
// mScene->init(300,200);
mView = new QGraphicsView ();
int del = 10;
// stateBox( new StateBox()),
qDebug() << "mh " << this->width() << this->height();
mScene->setSceneRect(0,0,300,200);
mGrid = new MakeGrid(this->mScene->width(), this->mScene->height(),del);
mSelected = new MakeSelected(this->mScene->width(), this->mScene->height(),del);
//mSelected->setPos(10,10);
////////
mLayout->addWidget(mView);
this->setLayout(mLayout);
mScene->addItem(mGrid);
mScene->addItem(mSelected);
mView->setScene( mScene);
mView->show();
mSelected->setFlag(QGraphicsItem::ItemIsSelectable,
true);
//mSelected->setFlag(QGraphicsItem::ItemIsMovable,
// true);
}
TabClass::~TabClass()
{
delete mGrid;
delete mScene;
delete mView;
delete mLayout;
// delete mSelected;
}
void TabClass::keyPressEvent(QKeyEvent *event)
{
// qDebug() << "key="<<event->key();
// qDebug() << event->modifiers() << event->key() <<
// (event->key() == Qt::Key_Shift) << event->isAutoRepeat();
if ( event->key() == Qt::Key_Shift )
{
qDebug() << "key=shift";
mSelected->shiftPressed = true;
}
else qDebug() << "NO NO NO key=shift";
// emit keyCaught(event);
/* if(event->key() == Qt::Key_Delete)
foreach(QGraphicsItem* item, selectedItems()){
removeItem(item);
delete item;
}
else*/
QWidget::keyPressEvent(event);
}
void TabClass::keyReleaseEvent(QKeyEvent *event)
{
// qDebug() << "released="<<event->key();
if ( event->key() == Qt::Key_Shift )
mSelected->shiftPressed = false;
// emit keyCaught(event);
/* if(event->key() == Qt::Key_Delete)
foreach(QGraphicsItem* item, selectedItems()){
removeItem(item);
delete item;
}
else*/
QWidget::keyReleaseEvent(event);
}