Qt实现TcpClient和TcpServer连接收发数据,TcpClent实现上位机给串口发送指令,没有什么问题了,可是让下位机做出相应的指令。
首先在TcpClient和TcpServer中的pro加入QT+=network。
界面设计:
接受指令设计:
tcpclient.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QWidget>
#include <QMainWindow>
#include <QDialog>
#include <QAbstractSocket>
class QTcpSocket;
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
priva