emsApplication/applications/emsConfigurer/mainwindow.cpp

38 lines
1.1 KiB
C++

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QPixmap>
#include <QMessageBox>
#include <QRegularExpression>
#include <QRegularExpressionValidator>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->setWindowIcon(QIcon(":/images/icon.png"));
QPixmap pixmap(":/images/hj-net.png");
pixmap = pixmap.scaled(250, 75, Qt::KeepAspectRatio, Qt::SmoothTransformation); // 按比例缩放
ui->label_logo->setPixmap(pixmap);
QString qsLineEditStyle("QLineEdit { min-height: 20px; min-width: 120px; }");
ui->userToken->setStyleSheet(qsLineEditStyle);
ui->serverIp->setStyleSheet(qsLineEditStyle);
QRegularExpression rx("^((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)$");
QRegularExpressionValidator* ipValidator = new QRegularExpressionValidator(rx, this);
ui->serverIp->setValidator(ipValidator);
setIp("127.0.0.1");
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::setIp(const QString &ip)
{
ui->serverIp->setText(ip);
}