hkc320 2024-09-10 16:55:41 +08:00
parent 3fc451546d
commit 7eebd994ec
6 changed files with 80 additions and 0 deletions

View File

@ -40,12 +40,15 @@ win32:LIBS += Ws2_32.lib
SOURCES += \ SOURCES += \
main.cpp \ main.cpp \
maindialog.cpp \
mainwindow.cpp mainwindow.cpp
HEADERS += \ HEADERS += \
maindialog.h \
mainwindow.h mainwindow.h
FORMS += \ FORMS += \
maindialog.ui \
mainwindow.ui mainwindow.ui
# Default rules for deployment. # Default rules for deployment.

View File

@ -0,0 +1,14 @@
#include "maindialog.h"
#include "ui_maindialog.h"
MainDialog::MainDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::MainDialog)
{
ui->setupUi(this);
}
MainDialog::~MainDialog()
{
delete ui;
}

View File

@ -0,0 +1,22 @@
#ifndef MAINDIALOG_H
#define MAINDIALOG_H
#include <QDialog>
namespace Ui {
class MainDialog;
}
class MainDialog : public QDialog
{
Q_OBJECT
public:
explicit MainDialog(QWidget *parent = nullptr);
~MainDialog();
private:
Ui::MainDialog *ui;
};
#endif // MAINDIALOG_H

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainDialog</class>
<widget class="QDialog" name="MainDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>867</width>
<height>665</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -5,9 +5,12 @@
#include <QRegularExpression> #include <QRegularExpression>
#include <QRegularExpressionValidator> #include <QRegularExpressionValidator>
#include "MainDialog.h"
MainWindow::MainWindow(QWidget *parent) MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent) : QMainWindow(parent)
, ui(new Ui::MainWindow) , ui(new Ui::MainWindow)
, m_pMainDialog(nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
this->setWindowIcon(QIcon(":/images/icon.png")); this->setWindowIcon(QIcon(":/images/icon.png"));
@ -29,9 +32,22 @@ MainWindow::MainWindow(QWidget *parent)
MainWindow::~MainWindow() MainWindow::~MainWindow()
{ {
delete ui; delete ui;
if (m_pMainDialog)
{
delete m_pMainDialog;
m_pMainDialog = nullptr;
}
} }
void MainWindow::setIp(const QString &ip) void MainWindow::setIp(const QString &ip)
{ {
ui->serverIp->setText(ip); ui->serverIp->setText(ip);
} }
void MainWindow::on_pb_Logon_clicked()
{
m_pMainDialog = new MainDialog();
m_pMainDialog->show();
this->close();
}

View File

@ -3,6 +3,8 @@
#include <QMainWindow> #include <QMainWindow>
class MainDialog;
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; } namespace Ui { class MainWindow; }
QT_END_NAMESPACE QT_END_NAMESPACE
@ -18,7 +20,11 @@ public:
protected: protected:
void setIp(const QString &ip); void setIp(const QString &ip);
private slots:
void on_pb_Logon_clicked();
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
MainDialog* m_pMainDialog;
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H