網絡和連接
Qt 提供用於高級網絡和低級網絡兩者通信的類、用於 Web 集成的類、及用於 IPC (進程間通信) 的類。
對於高級網絡流量,
Qt Network
提供僅展示高級類和函數,覆蓋所用操作的抽象層。Qt Network 還可以處理像 TCP 和 UDP 的低級協議。類
QTcpSocket
and
QUdpSocket
使開發者能夠使用 TCP 或 UDP 協議發送和接收消息。名稱解析的處理是采用
QHostInfo
.
QHostInfo
被調用,先於創建網絡連接采用
QTcpSocket
or
QUdpSocket
。可以處理憑藉代理過濾和重新分配網絡流量,通過
QNetworkProxy
類。
Qt 提供
連接
選項以連接係統或應用程序使用模塊,像
Qt Bluetooth
,提供在有啓用藍牙的設備之間的連接。
Qt Serial Bus
provides classes and functions to access the various industrial serial buses and protocols, and
Qt NFC
provides connectivity between NFC enabled devices. Also,
Qt Serial Port
provides the basic functionality, including configuring, I/O operations, and getting and setting the control signals of the RS-232 pinouts.
Qt 提供瞭功能為
進程間通信
。類
QProcess
被用於啓動外部程序。
Qt D-Bus
provides support for D-Bus, an inter-process communication and remote procedure calling mechanism. It communicates via a central server application called a bus. However, it is also possible to let applications communicate directly with each other.
QSharedMemory
provides access to a shared memory segment by multiple threads and processes. However, a single process can exclusively lock that shared memory.
網絡通信
Qt 支持廣泛網絡通信,重點是 HTTP、TCP 及 UDP。
在 HTTP 級彆,
Qt Network
模塊提供網絡訪問 API,主要包括
QNetworkRequest
,
QNetworkAccessManager
,和
QNetworkReply
。
QNetworkRequest
類似於 HTTP 請求,其被傳遞給
QNetworkAccessManager
以發送綫上請求;此類返迴
QNetworkReply
, which enables parsing the HTTP reply. The network access API internally uses the socket classes mentioned below (for TCP and SSL).
QTcpSocket
,
QUdpSocket
,和
QSslSocket
should be used for communication at the socket level. These classes offer a synchronous API through the waitFor* methods as well as an asynchronous API; if possible (that is if the event loop is running), the asynchronous API should always be preferred. Qt also offers
QTcpServer
to enable the server-side part of a TCP communication.
為憑藉 SSL 進行安全通信,Qt Network 提供廣泛的類,除瞭中心
QSslSocket
。例如,
QSslCertificate
,
QSslConfiguration
,和
QSslError
.
Qt 還在 QML 中提供 HTTP 支持,要麼憑藉 XmlHttpRequest 明確使用 HTTP,要麼通過透明地使用 HTTP URL (例如:在圖像源中)。
相關話題:
-
用 Qt 進行網絡編程
-
SSL (安全套接字層) 類
-
資源加載和網絡透明度
- 在 QML 中的網絡和 URL 透明度
-
Qt Network Authorization
- set of APIs that enable Qt applications to obtain limited access to online accounts and HTTP services without exposing users' passwords.
-
Qt Remote Objects
- an inter-process communication (IPC) module that enables information exchange between processes or computers.
-
Qt MQTT
- machine-to-machine (M2M) protocol that uses the publish-and-subscribe paradigm to provide a channel with minimal communication overhead.
-
Qt OPC UA
- server that offers access to data that is organized in a mesh of nodes connected by references. The use of different reference types and nodes containing metadata enables a client to navigate and interpret the data without knowing their structure in advance.
-
Qt WebSockets
- web-based protocol designed to enable a two-way interactive communication session between a client application and a remote host. It enables the two entities to send data back and forth if the initial handshake succeeds.
-
Qt WebChannel
- enables peer-to-peer communication between a server (QML/C++ application) and a client (HTML/JavaScript or QML application). It is supported out of the box by Qt
WebEngine
. In addition, it can work on all browsers that support WebSockets, enabling Qt WebChannel clients to run in any JavaScript environment (including QML). This requires implementing a custom transport based on Qt WebSockets.
-
Qt Protobuf
- a generator that can be used to generate Qt-based classes from
.proto
文件。
-
Qt GRPC
- allows you to define data and messages in proto files and then use the code generators, which generate code allowing accessors for fields and gRPC services in the Qt framework.
連接
Qt 支持一係列連接選項,重點是
Qt Serial Bus
,
Qt Serial Port
,
Qt Bluetooth
and
Qt NFC
.
-
Qt Serial Bus
- provides classes and functions to access the various industrial serial buses and protocols, such as CAN, ModBus, and others.
-
Qt Serial Port
- provides the basic functionality, which includes configuring, I/O operations, getting and setting the control signals of the RS-232 pinouts.
-
Qt Bluetooth
- provides classes and functions to use Bluetooth devices, which includes scanning for devices, gathering information, and exchanging data between them. Qt Bluetooth supports both Classic and Low Energy Bluetooth technologies.
-
Qt NFC
- provides classes and functions to establish connectivity between NFC enabled devices. NFC is a short-range (less than 20 centimeters) wireless technology with a maximum transfer rate of 424 Kbps. NFC is ideal for transferring small packets of data when two devices are placed together.
相關話題: