forked from PuddingPengChen/Qt-EncodeAndDecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecoderwidget.cpp
More file actions
39 lines (36 loc) · 925 Bytes
/
decoderwidget.cpp
File metadata and controls
39 lines (36 loc) · 925 Bytes
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
#include <QFileDialog>
#include <QMessageBox>
#include "decoderwidget.h"
#include "ui_decoderwidget.h"
DecoderWidget::DecoderWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::DecoderWidget)
{
ui->setupUi(this);
decode = new QZXing(QZXing::DecoderFormat_MAXICODE);
}
DecoderWidget::~DecoderWidget()
{
delete ui;
}
void DecoderWidget::on_btnInput_clicked()
{
file = QFileDialog::getOpenFileName(this,tr("选择二维码"),".",tr("Image (*.png *.jpg)"));
QPixmap pixmap(file);
ui->label->setPixmap(pixmap);
}
//解码输出
void DecoderWidget::on_btnOut_clicked()
{
QImage a(file);
QString strQRCode = decode->decodeImage(a);
if(!strQRCode.isEmpty())
{
ui->plainTextEdit->appendPlainText(strQRCode);
qDebug()<<tr("解析数据:")<<strQRCode;
}
else
{
QMessageBox::warning(this,tr("警告"),tr("识别二维码信息失败!"));
}
}