-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwidget.cpp
91 lines (74 loc) · 2.3 KB
/
widget.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
}
Widget::~Widget()
{
delete ui;
}
void Widget::on_pushButton_clicked()
{
QString str1 = ui->textEntering->toPlainText();
if (str1.trimmed() == "") {
return;
}
char *bufr;
QString str1__ = QString::fromUtf8(str1.toUtf8().toBase64());
QByteArray ba = str1__.toUtf8();
char *c_str2 = ba.data();
// #ifdef Q_PROCESSOR_X86_64
// QFile dllqr(":/new/res/files/qrcode_64.dll");
// dllqr.copy("qrcode_64.dll");
// qDebug() << dllqr.readLink();
// QLibrary lib("qrcode_64.dll");
// #endif
// #ifdef Q_PROCESSOR_X86_32
// QFile dllqr(":/new/res/files/qrcode_32.dll");
// dllqr.copy("qrcode_32.dll");
// qDebug() << dllqr.readLink();
// QLibrary lib("qrcode_32.dll");
// #endif
QFile dllqr(":/new/res/files/qrcode.dll");
dllqr.copy("qrcode.dll");
qDebug() << dllqr.readLink();
QLibrary lib("qrcode.dll");
if( !lib.load() ) {
ui->textEntering->setText("");
qDebug() << "Error! "+dllqr.readLink()+" not link";
} else {
typedef char* ( *InputTest )(char*, int);
InputTest inputTest = ( InputTest ) lib.resolve( "PrintQr" );
qDebug() << ui->spinBox->value();
bufr = inputTest(c_str2,ui->spinBox->value());
QString baa = QString::fromLocal8Bit(bufr);
QTextStream stream(&baa);
QByteArray base64Data = stream.readAll().toUtf8();
QImage image;
image.loadFromData(QByteArray::fromBase64(base64Data), "PNG");
ui->label->setPixmap(QPixmap::fromImage(image));
}
}
void Widget::on_pushButton_2_clicked()
{
on_pushButton_clicked();
QString str1 = ui->textEntering->toPlainText();
if (str1.trimmed() == "") {
return;
}
QFileDialog dialog(this);
dialog.setFileMode(QFileDialog::AnyFile);
dialog.setNameFilter(tr("Images (*.png)"));
QStringList fileNames;
if (dialog.exec()) {
fileNames = dialog.selectedFiles();
}
if (fileNames[0].toLower().contains(".png")) {
ui->label->pixmap()->toImage().save(fileNames[0], "PNG");
} else {
ui->label->pixmap()->toImage().save(fileNames[0]+".png", "PNG");
}
}