-
Notifications
You must be signed in to change notification settings - Fork 0
/
renderedwindow.cpp
78 lines (58 loc) · 1.6 KB
/
renderedwindow.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
76
77
#include "renderedwindow.h"
#include "ui_renderedwindow.h"
#include <QMouseEvent>
#include <QMenu>
#include <QDebug>
#include <QPoint>
#include <QFileDialog>
RenderedWindow::RenderedWindow(QWidget *parent) :
QWidget(parent),
ui(new Ui::RenderedWindow)
{
ui->setupUi(this);
RenderedWindow::setWindowTitle("Rendered");
this->setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)),
this, SLOT(ShowContextMenu(const QPoint &)));
QDir *dir = new QDir;
m_workDir = dir->currentPath();
QPixmap image(":/img/basic.png");
m_pimageScene = new QGraphicsScene();
m_pimageScene->addPixmap(image);
ui->graphicsView->setScene(m_pimageScene);
}
RenderedWindow::~RenderedWindow()
{
delete ui;
}
void RenderedWindow::mousePressEvent(QMouseEvent *event)
{
if(event->button() == Qt::RightButton)
{
}
}
void RenderedWindow::ShowContextMenu(const QPoint& pos) // this is a slot
{
// for most widgets
QPoint globalPos = this->mapToGlobal(pos);
// for QAbstractScrollArea and derived classes you would use:
// QPoint globalPos = myWidget->viewport()->mapToGlobal(pos);
QMenu myMenu;
myMenu.addAction("Menu Item 1");
// ...
QAction* selectedItem = myMenu.exec(globalPos);
if (selectedItem)
{
// something was chosen, do stuff
}
else
{
// nothing was chosen
}
}
void RenderedWindow::on_pushButton_clicked()
{
QString fileName = QFileDialog::getSaveFileName(this, tr("Save Image"),
m_workDir,
tr("Images (*.jpg)"));
}