導航:首頁 > 編程知識 > qt編程歌詞怎麼讀

qt編程歌詞怎麼讀

發布時間:2023-05-24 22:57:45

A. QT語言是什麼

Qt不是語言,是一個c++類庫,多用來編寫界面,但是qt類庫實際上非常全面,多線程、資料庫支持、IO和網路都支持。qt有自己的IDE qtcreator,也可以掛載在vs開發,支持跨平台(windows、linux),安卓也支持但是不推薦用qt寫安卓。Qt的文檔完整性和可讀性非常高,是真正可以照著文檔編程的(每個函數都有實例,每個參數都有解釋),目前語言支持c++(qt widget項目)、python(pyQt)、Qml(Qt quick項目),qml是qt自己的腳本,類似js

B. QT開發(五十)——QT串口編程基礎

一、QtSerialPort簡介

1、串口通信基礎

目前使用最廣泛的串口為DB9介面,適用於較近距離的通信。一般小於10米。DB9介面有9個針腳。

串口通信的主要參數如下:

A、波特率:衡量通信速度的參數,表示每秒鍾傳送的bit的個數。例如9600波特表示每秒鍾發送9600個bit。

B、數據位:衡量通信中實際數據位的參數,當計算機發送一個信息包,實際包含的有效數據位個數。

C、停止位:用於表示單個包的最後一位。典型的值為1和2位。

D、奇偶校驗位:串口通信中一種檢錯方式。常用的檢錯方式有:偶、奇校驗。

2、QtSerialPort模塊簡介

QtSerialPort模塊是QT5中附加模塊的一個模塊,為硬體和虛擬的串口提供統一的介面。

串口由於其簡單和可靠,目前在像嵌入式系統、機器人等工業中依舊用得很多。使用QtSerialPort模塊,開發者可以大大縮短開發串口相關的應用程的周期。

Qt SerialPort提供了基本的功能,包括配置、I/O操作、獲取和設置RS-232引腳的信號。

Qt SerialPort模塊暫不支持以下特性:

A、終端的特性,例如回顯,控制CR/LF等等

B、文本模式

C、讀或寫操作的超時和延時配置

D、當RS-232引腳信號變化通知

#include <QtSerialPort/QtSerialPort>

要鏈接QtSerialPort模塊,需要在.pro文件中添加如下內容:

QT += serialport

二、QSerialPort

1、QSerialPort簡介

QSerialPort提供了訪問串口的介面函數。使用輔助類QSerialPortInfo可以獲取可用的串口信息。將QSerialPortInfo輔助類對象做為參數,使用setPort()或setPortName()函數可以設置要訪問的串口設備。

設置好埠後,可以使用open()函數以只讀、只寫或讀寫的模式打開使用。

注意,串口使用獨占方式打開。

使用close()函數關閉串口並且取消IO操作。

串口成功打開後,QSerialPort會嘗試確定串口的當前配置並初始化。可以使用setBaudRate()、setDataBits()、setParity()、setStopBits()和setFlowControl()函數重新配置埠設置。

有一對名為QSerialPort::dataTerminalReady、QSerialPort::requestToSend的屬性

QSerialPort提供了中止正在調用線程直到信號觸發的一系列函數。這些函數用於阻塞串口。

waitForReadyRead():阻塞調用,直到有新的數據可讀

waitForBytesWritten():阻塞調用,直到數據以及寫入串口

阻塞串口編程與非阻塞串口編程完全不同。阻塞串口不會要求時間循環並且通常會簡化代碼。然而,在GUI程序中,為了避免凍結用戶界面,阻塞串口編程只能用於非GUI線程。

QSerialPort也能使用QTextStream和QDataStream的流操作符。在試圖使用流操作符>>讀時,需要確保有足夠可用的數據。

2、QSerialPort成員函數

QSerialPort::QSerialPort(QObject *parent = Q_NULLPTR)

QSerialPort::QSerialPort(const QString &name, QObject *parent = Q_NULLPTR)

QSerialPort::QSerialPort(const QSerialPortInfo &serialPortInfo, QObject *parent = Q_NULLPTR)

[virtual] bool QSerialPort::atEnd() const

[signal] void QSerialPort::baudRateChanged(qint32 baudRate, QSerialPort::Directions directions)

[virtual] qint64 QSerialPort::bytesAvailable() const

[virtual] qint64 QSerialPort::bytesToWrite() const

[virtual] void QSerialPort::close()

void QSerialPort::setPort(const QSerialPortInfo &serialPortInfo)

void QSerialPort::setPortName(const QString &name)

三、QSerialPortInfo

1、QSerialPortInfo簡介

QSerialPortInfo類提供已有串口設備的信息。使用QSerialPortInfo類的靜態成員函數生成QSerialPortInfo對象的鏈表。鏈表中的每個QSerialPortInfo對象代表一個串口,每個串口可以使用埠名、系統定位、描述、製造商查詢。QSerialPortInfo類對象也可以用做QSerialPort類的setPort()成員函數的參數。

2、QSerialPortInfo成員函數

QSerialPortInfo::QSerialPortInfo(const QSerialPort &port)

QSerialPortInfo::QSerialPortInfo(const QString &name)

QSerialPortInfo::QSerialPortInfo(const QSerialPortInfo &other)

[static] QList<QSerialPortInfo> QSerialPortInfo::availablePorts()

QString QSerialPortInfo::description() const

bool QSerialPortInfo::hasProctIdentifier() const

bool QSerialPortInfo::hasVendorIdentifier() const

bool QSerialPortInfo::isBusy() const

QString QSerialPortInfo::manufacturer() const

QString QSerialPortInfo::portName() const

quint16 QSerialPortInfo::proctIdentifier() const

QString QSerialPortInfo::serialNumber() const

[static] QList<qint32> QSerialPortInfo::standardBaudRates()

void QSerialPortInfo::swap(QSerialPortInfo &other)

QString QSerialPortInfo::systemLocation() const

quint16 QSerialPortInfo::vendorIdentifier() const

3、QSerialPortInfo顯示串口信息實例

閱讀全文

與qt編程歌詞怎麼讀相關的資料

熱點內容
淘寶升級是不是免費的 瀏覽:819
西安萬利網路科技有限公司怎麼樣 瀏覽:125
段位只是一個數據多少人吵散了 瀏覽:722
雙網卡上不同網路 瀏覽:94
拳皇game怎麼打壓縮文件 瀏覽:748
有哪些兩級配送物流網路 瀏覽:8
sql目錄名加文件名 瀏覽:446
小學編程教材哪個好 瀏覽:179
英語詞典蘋果app 瀏覽:344
黨的文件保管採用什麼辦法 瀏覽:45
老版本的百度雲盤 瀏覽:201
一指彈app怎麼用 瀏覽:249
ps怎麼提取文件名 瀏覽:540
蘋果7plus網路連接超時 瀏覽:959
權重6網站賣多少 瀏覽:151
bzb網站有哪些 瀏覽:687
機械類專業要學什麼編程 瀏覽:89
SQL中打開excel文件 瀏覽:468
藍牙可以傳word文件嗎 瀏覽:65
三星能自己升級系統嗎 瀏覽:265

友情鏈接