QT中的QSOCKET编程

这篇博客展示了如何在QT中利用QSocketDevice类实现UDP通信,创建了一个对话框,包含发送、接收和退出按钮,通过定时器定时发送'hello'字符串,并接收并显示来自127.0.0.1的回应。
摘要由CSDN通过智能技术生成

以下是用QT实现的利用SOCKET编程的例子,两端分别定时向对方放松hello串

.h文件

 /****************************************************************************
** Form interface generated from reading ui file 'newprojectdialog.ui'
**
** Created: 鏄熸湡浜?涓夋湀 7 13:54:58 2008
**      by: The User Interface Compiler ($Id: qt/main.cpp   3.2.1   edited May 19 14:22 $)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/

#ifndef NEWPROJECTDIALOG_H
#define NEWPROJECTDIALOG_H

#include <qvariant.h>
#include <qdialog.h>
#include <qsocketdevice.h>
#include <qsocketnotifier.h>
#include <qstring.h>

class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QPushButton;
class QLineEdit;
class QTextEdit;

class NewProjectDialog : public QDialog
{
    Q_OBJECT

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值