添加广播MDNS服务
This commit is contained in:
80
FactoryTestTool/SourceCode/Network/ImageEnrollWindow.h
Normal file
80
FactoryTestTool/SourceCode/Network/ImageEnrollWindow.h
Normal file
@@ -0,0 +1,80 @@
|
||||
#ifndef IMAGEENROLLWINDOW_H
|
||||
#define IMAGEENROLLWINDOW_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QFileDialog>
|
||||
#include <QLabel>
|
||||
|
||||
class ImageEnrollWindow : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ImageEnrollWindow(QWidget* parent = nullptr)
|
||||
: QDialog(parent)
|
||||
{
|
||||
QVBoxLayout* mainLayout = new QVBoxLayout(this);
|
||||
|
||||
QLabel* label = new QLabel("请选择注册的图片:", this);
|
||||
mainLayout->addWidget(label);
|
||||
|
||||
QHBoxLayout* inputLayout = new QHBoxLayout;
|
||||
filePathLineEdit = new QLineEdit(this);
|
||||
filePathLineEdit->setReadOnly(true);
|
||||
filePathLineEdit->setPlaceholderText("请选择PNG图片路径...");
|
||||
QPushButton* browseButton = new QPushButton("选择图片路径", this);
|
||||
|
||||
inputLayout->addWidget(filePathLineEdit);
|
||||
inputLayout->addWidget(browseButton);
|
||||
|
||||
mainLayout->addLayout(inputLayout);
|
||||
|
||||
QHBoxLayout* buttonLayout = new QHBoxLayout;
|
||||
QPushButton* confirmButton = new QPushButton("确认", this);
|
||||
QPushButton* cancelButton = new QPushButton("取消", this);
|
||||
|
||||
buttonLayout->addWidget(confirmButton);
|
||||
buttonLayout->addWidget(cancelButton);
|
||||
|
||||
mainLayout->addLayout(buttonLayout);
|
||||
setWindowTitle("选择图片");
|
||||
resize(460, 110); // 设置对话框的大小
|
||||
|
||||
connect(browseButton, &QPushButton::clicked, this, &ImageEnrollWindow::onBrowseButtonClicked);
|
||||
connect(confirmButton, &QPushButton::clicked, this, &QDialog::accept);
|
||||
connect(cancelButton, &QPushButton::clicked, this, &QDialog::reject);
|
||||
}
|
||||
|
||||
QString getFilePath() const {
|
||||
return filePathLineEdit->text();
|
||||
}
|
||||
|
||||
QByteArray getImageData() const {
|
||||
QString filePath = filePathLineEdit->text();
|
||||
if (!filePath.isEmpty()) {
|
||||
QFile file(filePath);
|
||||
if (file.open(QIODevice::ReadOnly)) {
|
||||
QByteArray imageData = file.readAll();
|
||||
return imageData.toBase64();
|
||||
}
|
||||
}
|
||||
return QByteArray();
|
||||
}
|
||||
|
||||
private slots:
|
||||
void onBrowseButtonClicked() {
|
||||
QString filePath = QFileDialog::getOpenFileName(this, tr("选择图片"), "", tr("Images (*.png *.xpm *.jpg *.bmp);;All Files (*)"));
|
||||
if (!filePath.isEmpty()) {
|
||||
filePathLineEdit->setText(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
QLineEdit* filePathLineEdit;
|
||||
};
|
||||
|
||||
#endif // IMAGEENROLLWINDOW_H
|
||||
Reference in New Issue
Block a user