UDP:
1、用到网络的东西,必须修改工程环境变量,添加: QT += core gui network
2、用到类 QudpSocket ;
Detailed Description
The QUdpSocket class provides a UDP socket.
UDP (User Datagram Protocol) is a lightweight, unreliable,datagram-oriented, connectionless protocol. It can be used when reliabilityisn't important. QUdpSocket is a subclass of QAbstractSocket that allows you to send and receiveUDP datagrams.
The most common way to use this class is to bind to anaddress and port using bind(), thencall writeDatagram()andreadDatagram()to transfer data. If you want to use the standard QIODevice functions read(), readLine(), write(), etc., you must first connect thesocket directly to a peer by calling connectToHost().
The socket emits the bytesWritten()signal every time a datagram is written to the network. If you just want tosend datagrams, you don't need to call bind().
The readyRead()signal is emitted whenever datagrams arrive. In that case, hasPendingDatagrams()returns true. Call