RecRepView
::RecRepView(QWidget *parent
){
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setFrameShape
(QFrame::NoFrame);
setCacheMode(CacheBackground);
setViewportUpdateMode(FullViewportUpdate);
setStyleSheet("background:#00002E");
QRectF bounds
(0,
-20,
700,
500);
setScene(scene);
this->installEventFilter(this);
int i =0;
mapValue[i] = STARTVALUE;
button1
= new GraphButton
(QRectF(0,
0,
150,
40),
1);
button1->setPos(475, 330);
scene->addItem(button1);
connect(button1, SIGNAL(activated()), signalMapper, SLOT(map()));
signalMapper->setMapping(button1,mapValue[i]);
i++;
mapValue[i] = STOPVALUE;
button2
= new GraphButton
(QRectF(0,
0,
150,
40),
2);
button2->setPos(475, 400);
scene->addItem(button2);
connect(button2, SIGNAL(activated()), signalMapper, SLOT(map()));
signalMapper->setMapping(button2,mapValue[i]);
logout
= new BackItem
(QRectF(0,
0,
70,
65));
logout->setPos(20, 405);
// log connect(logout, SIGNAL(closeSignal()), qApp, SLOT(quit()));
scene->addItem(logout);
connect(signalMapper, SIGNAL(mapped(int )), this, SIGNAL(activated(int)));
connect(this, SIGNAL(activated(int )), this, SLOT(recRepSlot(int )));
}
{
fitInView(scene->sceneRect(), Qt::KeepAspectRatio);
}
void RecRepView
::drawBackground(QPainter *painter,
const QRectF &rect
) {
Q_UNUSED(rect);
QRectF rects
(450,
310,
200,
160);
painter
->setBrush
(QColor(128,
128,
128));
painter->setPen(pen);
painter->drawRect(rects);
{
if(ob
== logout
&& e
->type
() == QEvent::KeyPress) { const QKeyEvent *ke
= static_cast<QKeyEvent
*>
(e
);
if(ke->key()==Qt::Key_F1){
printf("is it coming inside ..\n");
}
return true;
}
return QWidget::eventFilter(ob, e
);
}
void RecRepView::recRepSlot(int value)
{
printf("the value coming inside :%d \n", value);
}
RecRepView::RecRepView(QWidget *parent)
: QGraphicsView(parent)
{
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setFrameShape(QFrame::NoFrame);
setCacheMode(CacheBackground);
setViewportUpdateMode(FullViewportUpdate);
setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
setStyleSheet("background:#00002E");
QRectF bounds(0, -20, 700, 500);
scene = new QGraphicsScene(bounds, this);
setScene(scene);
this->installEventFilter(this);
signalMapper = new QSignalMapper();
int i =0;
mapValue[i] = STARTVALUE;
button1 = new GraphButton(QRectF(0,0, 150, 40), 1);
button1->setFlag(QGraphicsItem::ItemIsSelectable);
button1->setPos(475, 330);
scene->addItem(button1);
connect(button1, SIGNAL(activated()), signalMapper, SLOT(map()));
signalMapper->setMapping(button1,mapValue[i]);
i++;
mapValue[i] = STOPVALUE;
button2 = new GraphButton(QRectF(0,0, 150, 40), 2);
button2->setFlag(QGraphicsItem::ItemIsSelectable);
button2->setPos(475, 400);
scene->addItem(button2);
connect(button2, SIGNAL(activated()), signalMapper, SLOT(map()));
signalMapper->setMapping(button2,mapValue[i]);
logout = new BackItem(QRectF(0, 0, 70, 65));
logout->setPos(20, 405);
logout->setFlag(QGraphicsItem::ItemIsSelectable);
// log connect(logout, SIGNAL(closeSignal()), qApp, SLOT(quit()));
scene->addItem(logout);
connect(signalMapper, SIGNAL(mapped(int )), this, SIGNAL(activated(int)));
connect(this, SIGNAL(activated(int )), this, SLOT(recRepSlot(int )));
}
void RecRepView ::resizeEvent(QResizeEvent *event)
{
QGraphicsView::resizeEvent(event);
fitInView(scene->sceneRect(), Qt::KeepAspectRatio);
}
void RecRepView::drawBackground(QPainter *painter, const QRectF &rect)
{
Q_UNUSED(rect);
QRectF rects(450,310, 200, 160);
QPen pen(QColor(211, 210, 212), 0.5);
painter->setBrush(QColor(128, 128, 128));
painter->setPen(pen);
painter->drawRect(rects);
}bool RecRepView:: eventFilter(QObject *ob, QEvent *e)
{
if(ob == logout && e->type() == QEvent::KeyPress) {
const QKeyEvent *ke = static_cast<QKeyEvent *>(e);
if(ke->key()==Qt::Key_F1){
printf("is it coming inside ..\n");
}
return true;
}
return QWidget::eventFilter(ob, e);
}
void RecRepView::recRepSlot(int value)
{
printf("the value coming inside :%d \n", value);
}
To copy to clipboard, switch view to plain text mode
Bookmarks