ui 0.3 添加图案投影拍照后展示照片的界面 DisplayPic

This commit is contained in:
Norah
2020-02-03 15:37:04 +08:00
parent f4d6cc81b5
commit 8ae4c44bec
7 changed files with 199 additions and 19 deletions

View File

@@ -2,6 +2,7 @@
#include <QMessageBox>
#include <QFileDialog>
#include <QColorDialog>
#include "DisplayPic.h"
Reconstruction::Reconstruction(QWidget *parent)
: QMainWindow(parent)
@@ -10,21 +11,6 @@ Reconstruction::Reconstruction(QWidget *parent)
ui.stackedWidget->setCurrentIndex(0);
/* 如果用on_XXX_clicked()定义槽Qt的元对象QMetaObject会自动的寻找相关的信号并链接不能再用connect()链接了,否则就会连接两次。
connect(ui.pushButton, SIGNAL(clicked()), this, SLOT(on_pushButton_clicked()));
connect(ui.pushButton_2, SIGNAL(clicked()), this, SLOT(on_pushButton_2_clicked()));
connect(ui.pushButton_3, SIGNAL(clicked()), this, SLOT(on_pushButton_3_clicked()));
connect(ui.pushButton_4, SIGNAL(clicked()), this, SLOT(on_pushButton_4_clicked()));
connect(ui.pushButton_5, SIGNAL(clicked()), this, SLOT(on_pushButton_5_clicked()));
connect(ui.pushButton_6, SIGNAL(clicked()), this, SLOT(on_pushButton_6_clicked()));
connect(ui.pushButton_7, SIGNAL(clicked()), this, SLOT(on_pushButton_7_clicked()));
connect(ui.pushButton_8, SIGNAL(clicked()), this, SLOT(on_pushButton_8_clicked()));
connect(ui.pushButton_9, SIGNAL(clicked()), this, SLOT(on_pushButton_9_clicked()));
connect(ui.pushButton_10, SIGNAL(clicked()), this, SLOT(on_pushButton_10_clicked()));
connect(ui.pushButton_11, SIGNAL(clicked()), this, SLOT(on_pushButton_11_clicked()));
connect(ui.pushButton_12, SIGNAL(clicked()), this, SLOT(on_pushButton_12_clicked()));
connect(ui.pushButton_13, SIGNAL(clicked()), this, SLOT(on_pushButton_13_clicked()));
connect(ui.pushButton_14, SIGNAL(clicked()), this, SLOT(on_pushButton_14_clicked()));
connect(ui.pushButton_15, SIGNAL(clicked()), this, SLOT(on_pushButton_15_clicked()));
connect(ui.pushButton_16, SIGNAL(clicked()), this, SLOT(on_pushButton_16_clicked()));
*/
}
@@ -139,8 +125,25 @@ void Reconstruction::on_pushButton_4_clicked()
void Reconstruction::on_pushButton_9_clicked()
{
// todo 相机拍照
QString picUrl = "Resources/image/test.png"; // 存储拍摄照片
// todo 然后出来一个界面 拍摄到的照片,然后下面三个按钮:确定 取消
DisplayPic *picDlg = new DisplayPic();
picDlg->setPicUrl(picUrl);
connect(picDlg, SIGNAL(getPicAction(QString)), this, SLOT(setPicAction(QString)));
picDlg->show();
}
void Reconstruction::setPicAction(QString action)
{
if(action=="confirmed")
{
qDebug("confirmed");
// todo 存储图片路径
}else if(action=="canceled")
{
qDebug("canceled");
// 用户再拍一次 无需操作
}
}
// 保存照片

View File

@@ -12,6 +12,7 @@ public:
private:
Ui::ReconstructionClass ui;
private slots:
void on_pushButton_clicked();
@@ -30,4 +31,5 @@ private slots:
void on_pushButton_14_clicked();
void on_pushButton_15_clicked();
void on_pushButton_16_clicked();
void setPicAction(QString action);
};

38
DisplayPic.cpp Normal file
View File

@@ -0,0 +1,38 @@
#include "DisplayPic.h"
DisplayPic::DisplayPic(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
}
DisplayPic::~DisplayPic()
{
}
void DisplayPic::setPicUrl(QString pic)
{
picUrl = pic;
if(picUrl.isEmpty())
{
ui.label->setText("No Photo Taken");
}else
{
ui.label->setPixmap(QPixmap(picUrl));
}
}
// È·¶¨
void DisplayPic::on_pushButton_clicked()
{
emit getPicAction("confirmed");
this->close();
}
// È¡Ïû
void DisplayPic::on_pushButton_2_clicked()
{
emit getPicAction("canceled");
this->close();
}

25
DisplayPic.h Normal file
View File

@@ -0,0 +1,25 @@
#pragma once
#include <QWidget>
#include "ui_DisplayPic.h"
class DisplayPic : public QWidget
{
Q_OBJECT
public:
DisplayPic(QWidget *parent = Q_NULLPTR);
~DisplayPic();
void setPicUrl(QString pic);
private:
Ui::DisplayPic ui;
QString picUrl;
private slots:
void on_pushButton_clicked();
void on_pushButton_2_clicked();
signals:
void getPicAction(QString action);
};

93
DisplayPic.ui Normal file
View File

@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DisplayPic</class>
<widget class="QWidget" name="DisplayPic">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>684</width>
<height>497</height>
</rect>
</property>
<property name="windowTitle">
<string>DisplayPic</string>
</property>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>661</width>
<height>421</height>
</rect>
</property>
<property name="title">
<string/>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>621</width>
<height>371</height>
</rect>
</property>
<property name="font">
<font>
<family>Adobe Devanagari</family>
<pointsize>20</pointsize>
</font>
</property>
<property name="text">
<string>PIC</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</widget>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>120</x>
<y>450</y>
<width>93</width>
<height>28</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string>确定</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_2">
<property name="geometry">
<rect>
<x>440</x>
<y>450</y>
<width>93</width>
<height>28</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string>取消</string>
</property>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

View File

@@ -16,8 +16,8 @@
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>340</x>
<y>150</y>
<x>360</x>
<y>200</y>
<width>151</width>
<height>41</height>
</rect>
@@ -25,7 +25,7 @@
<property name="font">
<font>
<family>Adobe Devanagari</family>
<pointsize>18</pointsize>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
@@ -64,6 +64,25 @@
<string>按任意键进入</string>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>260</x>
<y>120</y>
<width>321</width>
<height>41</height>
</rect>
</property>
<property name="font">
<font>
<family>Adobe Devanagari</family>
<pointsize>20</pointsize>
</font>
</property>
<property name="text">
<string>3D RECONSTRUCTION</string>
</property>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>

BIN
Resources/image/test.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 307 KiB