feat: UDP 创建界面好了,和部分槽函数

This commit is contained in:
touwoyimuli
2019-11-30 00:00:53 +08:00
parent 098d039040
commit 50d0530a55
15 changed files with 386 additions and 6 deletions

View File

@@ -0,0 +1,56 @@
/*
* Copyright (C) 2019 ~ 2019 touwoyimuli. All rights reserved.
*
* Author: touwoyimuli <touwoyimuli@gmai.com>
*
* github: https://github.com/touwoyimuli
* blogs: https://touwoyimuli.github.io/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://touwoyimuli.github.io/>.
*/
#include "ExTrans.h"
#include "ui_ExTrans.h"
ExTrans::ExTrans(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::ExTrans)
{
ui->setupUi(this);
setWindowTitle("Tcp通信unicast(单播) + broadcast(广播)的使用");
}
ExTrans::~ExTrans()
{
delete ui;
}
void ExTrans::on_actBind_triggered()
{
}
void ExTrans::on_actDisbind_triggered()
{
}
void ExTrans::on_actClean_triggered()
{
}
void ExTrans::on_actQuit_triggered()
{
close();
}

49
QtUdpEx/ExTrans/ExTrans.h Normal file
View File

@@ -0,0 +1,49 @@
/*
* Copyright (C) 2019 ~ 2019 touwoyimuli. All rights reserved.
*
* Author: touwoyimuli <touwoyimuli@gmai.com>
*
* github: https://github.com/touwoyimuli
* blogs: https://touwoyimuli.github.io/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://touwoyimuli.github.io/>.
*/
#ifndef EXTRANS_H
#define EXTRANS_H
#include <QMainWindow>
namespace Ui {
class ExTrans;
}
class ExTrans : public QMainWindow
{
Q_OBJECT
public:
explicit ExTrans(QWidget *parent = nullptr);
~ExTrans();
private slots:
void on_actBind_triggered();
void on_actDisbind_triggered();
void on_actClean_triggered();
void on_actQuit_triggered();
private:
Ui::ExTrans *ui;
};
#endif // EXTRANS_H

View File

@@ -0,0 +1,55 @@
#-------------------------------------------------
#
# Project created by QtCreator 2019-11-29T22:57:12
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = ExTrans
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
CONFIG += c++11
SOURCES += \
main.cpp \
ExTrans.cpp
HEADERS += \
ExTrans.h
FORMS += \
ExTrans.ui
macx {
ICON = images/icon.icns
}
unix:!macx{
# linux only
}
win32 {
RC_ICONS = images/icon.ico
}
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
RESOURCES += \
resources.qrc

186
QtUdpEx/ExTrans/ExTrans.ui Normal file
View File

@@ -0,0 +1,186 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ExTrans</class>
<widget class="QMainWindow" name="ExTrans">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>671</width>
<height>448</height>
</rect>
</property>
<property name="windowTitle">
<string>ExTrans</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>绑定端口:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox">
<property name="maximum">
<number>65000</number>
</property>
<property name="value">
<number>8888</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>目标地址:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>目标端口:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_2">
<property name="maximum">
<number>65000</number>
</property>
<property name="value">
<number>10000</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLineEdit" name="lineEdit"/>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>单播发送</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>广播发送</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPlainTextEdit" name="plainTextEdit"/>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>671</width>
<height>25</height>
</rect>
</property>
</widget>
<widget class="QToolBar" name="mainToolBar">
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="actBind"/>
<addaction name="actDisbind"/>
<addaction name="separator"/>
<addaction name="actClean"/>
<addaction name="separator"/>
<addaction name="actQuit"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="actBind">
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/images/Image6.png</normaloff>:/images/Image6.png</iconset>
</property>
<property name="text">
<string>绑定</string>
</property>
<property name="toolTip">
<string>绑定端口</string>
</property>
</action>
<action name="actDisbind">
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/images/Image3.png</normaloff>:/images/Image3.png</iconset>
</property>
<property name="text">
<string>解绑定</string>
</property>
<property name="toolTip">
<string>解除绑定</string>
</property>
</action>
<action name="actClean">
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/images/Image1.png</normaloff>:/images/Image1.png</iconset>
</property>
<property name="text">
<string>清空</string>
</property>
<property name="toolTip">
<string>清空文本</string>
</property>
</action>
<action name="actQuit">
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/images/Image2.jpg</normaloff>:/images/Image2.jpg</iconset>
</property>
<property name="text">
<string>退出</string>
</property>
<property name="toolTip">
<string>退出程序</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
<include location="resources.qrc"/>
</resources>
<connections/>
</ui>

Binary file not shown.

After

Width:  |  Height:  |  Size: 603 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 803 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 B

BIN
QtUdpEx/ExTrans/images/icon.icns Executable file

Binary file not shown.

BIN
QtUdpEx/ExTrans/images/icon.ico Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

11
QtUdpEx/ExTrans/main.cpp Normal file
View File

@@ -0,0 +1,11 @@
#include "ExTrans.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
ExTrans w;
w.show();
return a.exec();
}

View File

@@ -0,0 +1,10 @@
<RCC>
<qresource prefix="/">
<file>images/Image1.png</file>
<file>images/Image2.jpg</file>
<file>images/Image3.png</file>
<file>images/Image4.png</file>
<file>images/Image5.png</file>
<file>images/Image6.png</file>
</qresource>
</RCC>