mirror of
https://gitee.com/drabel/LibQQt.git
synced 2025-01-04 10:18:44 +08:00
add qqt udp example
This commit is contained in:
parent
abc6f91df0
commit
c6ba124ee1
6
QQt.pro
6
QQt.pro
@ -22,7 +22,11 @@ SUBDIRS = src/qqt.pro
|
||||
#SUBDIRS += examples/exquisite
|
||||
#SUBDIRS += examples/tabwidgetexamples
|
||||
#SUBDIRS += examples/qrcodeexample
|
||||
#SUBDIRS += examples/qqtnetworkexample
|
||||
#
|
||||
SUBDIRS += examples/qqtnetworkexample
|
||||
#udp 嵌入式linux,Qt编译了udp后支持
|
||||
#
|
||||
SUBDIRS += examples/qqtudpexample
|
||||
#SUBDIRS += examples/qqtchartexample
|
||||
#
|
||||
#
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "cedianudpprotocol.h"
|
||||
|
||||
|
||||
MainWindow::MainWindow ( QWidget* parent ) :
|
||||
@ -9,20 +8,6 @@ MainWindow::MainWindow ( QWidget* parent ) :
|
||||
{
|
||||
ui->setupUi ( this );
|
||||
|
||||
/*初始化端口*/
|
||||
qint32 nPort[9] = {0};
|
||||
|
||||
for ( int i = 0 ; i < 9; i++ )
|
||||
{
|
||||
//int port = ui->widget_12->getLocalPort ( i + 1 );
|
||||
/*正式版*/
|
||||
//nPort[i] = port;
|
||||
/*有规律版*/
|
||||
nPort[i] = 7000 + i * 10;
|
||||
//pline() << nPort[i];
|
||||
}
|
||||
|
||||
cedianUdpPort ( 5, nPort );
|
||||
// serialport example
|
||||
// tcpsocket example
|
||||
// websocket?
|
||||
|
@ -29,12 +29,7 @@ SOURCES += \
|
||||
qqtnetworkmessage.cpp \
|
||||
qqtserialmessage.cpp \
|
||||
qqtuserserialprotocol.cpp \
|
||||
qqtsubprotocoltest.cpp \
|
||||
cedianudpmessage.cpp \
|
||||
cedianudpprotocol.cpp \
|
||||
cedianudpserver.cpp \
|
||||
kongzhiqiudpmessage.cpp \
|
||||
kongzhiqiudpprotocol.cpp
|
||||
qqtsubprotocoltest.cpp
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h \
|
||||
@ -43,12 +38,7 @@ HEADERS += \
|
||||
qqtnetworkmessage.h \
|
||||
qqtserialmessage.h \
|
||||
qqtuserserialprotocol.h \
|
||||
qqtsubprotocoltest.h \
|
||||
cedianudpmessage.h \
|
||||
cedianudpprotocol.h \
|
||||
cedianudpserver.h \
|
||||
kongzhiqiudpmessage.h \
|
||||
kongzhiqiudpprotocol.h
|
||||
qqtsubprotocoltest.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui
|
||||
|
11
examples/qqtudpexample/main.cpp
Normal file
11
examples/qqtudpexample/main.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include "mainwindow.h"
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
29
examples/qqtudpexample/mainwindow.cpp
Normal file
29
examples/qqtudpexample/mainwindow.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "cedianudpprotocol.h"
|
||||
|
||||
MainWindow::MainWindow ( QWidget* parent ) :
|
||||
QMainWindow ( parent ),
|
||||
ui ( new Ui::MainWindow )
|
||||
{
|
||||
ui->setupUi ( this );
|
||||
/*初始化端口*/
|
||||
qint32 nPort[9] = {0};
|
||||
|
||||
for ( int i = 0 ; i < 9; i++ )
|
||||
{
|
||||
//int port = ui->widget_12->getLocalPort ( i + 1 );
|
||||
/*正式版*/
|
||||
//nPort[i] = port;
|
||||
/*有规律版*/
|
||||
nPort[i] = 7000 + i * 10;
|
||||
//pline() << nPort[i];
|
||||
}
|
||||
|
||||
cedianUdpPort ( 5, nPort );
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
22
examples/qqtudpexample/mainwindow.h
Normal file
22
examples/qqtudpexample/mainwindow.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
21
examples/qqtudpexample/mainwindow.ui
Normal file
21
examples/qqtudpexample/mainwindow.ui
Normal file
@ -0,0 +1,21 @@
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>480</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget" />
|
||||
</widget>
|
||||
<layoutDefault spacing="6" margin="11" />
|
||||
<pixmapfunction></pixmapfunction>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
53
examples/qqtudpexample/qqtudpexample.pro
Normal file
53
examples/qqtudpexample/qqtudpexample.pro
Normal file
@ -0,0 +1,53 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2018-01-30T15:14:36
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
TARGET = qqtudpexample
|
||||
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
|
||||
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
mainwindow.cpp \
|
||||
cedianudpmessage.cpp \
|
||||
cedianudpprotocol.cpp \
|
||||
cedianudpserver.cpp \
|
||||
kongzhiqiudpmessage.cpp \
|
||||
kongzhiqiudpprotocol.cpp
|
||||
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h \
|
||||
cedianudpmessage.h \
|
||||
cedianudpprotocol.h \
|
||||
cedianudpserver.h \
|
||||
kongzhiqiudpmessage.h \
|
||||
kongzhiqiudpprotocol.h
|
||||
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui
|
||||
|
||||
CONFIG += mobility
|
||||
MOBILITY =
|
||||
|
||||
#促使编译源代码,qmake pri配置里面的QMAKE_XX_LINK命令就会执行。
|
||||
system("touch main.cpp")
|
||||
include(../../src/app_base_manager.pri)
|
Loading…
x
Reference in New Issue
Block a user