QML型別說明 BluetoothSocket

2021-06-25 07:06:04 字數 1338 閱讀 6143

bluetoothsocket

import statement:   import qtbluetooth 5.2

since:  qt 5.2

properties

connected :bool

error :enumeration

service :bluetoothservice

state :enumeration

stringdata :string

detaileddescription

它允許qml類能和另乙個裝置進行藍芽連線並交換字串。在這個元件中,資料的傳送和接收都使用qdatastream來傳輸qstrings。qdatastream是眾所周知的資料格式,能被非qt程式解碼。

注意:這個元件只能傳輸字串,如果我們希望傳輸二進位制資料,應該使用對應的c++的qbluetoothsocket類。同時參閱qbluetoothsocket和qdatastream。

propertydocumentation

connected :bool

socket的連線狀態。如果建立對等連線,這個屬性返回真。不能通過設定這個屬性來控制是否連線。當設定它為真時,在連線建立之前,它將不會返回真。

error :enumeration

這個屬性是最後發生的錯誤。

noerror

unknownsocketerror

hostnotfounderror

servicenotfounderror

networkerror

unsupportedprotocolerror

錯誤是qbluetoothsocket::socketerror的派生,這個屬性是唯讀的。

service :bluetoothservice

連線的遠端服務的詳細資訊。它能被設定成乙個靜態藍芽服務的固定描述,也能是被發現的服務返回的資訊。

state : enumeration

當前socket的狀態。

noserviceset

unconnected

servicelookup

connecting

connected

closing

listening

bound

狀態由qbluetoothsocket::socketstate派生,這個屬性是唯讀的。

stringdata :string

被接受或傳送到遠端藍芽裝置的資料。抵達的資料能通過鏈結到這個屬性的訊號探測到。可使用onstringdatachanged檢測資料抵達,然後通過讀這個屬性獲得資料。往這個屬性寫資料將被傳送,如果傳送的資料過多,將會阻塞傳送,讀不會被阻塞。

QML型別說明 AnimatedSprite

animatedsprite importstatement import qtquick2.2 inherits item properties currentframe int framecount int frameduration int frameheight int framerate ...

QML型別說明 AudioSample

audiosample importstatement import qtaudioengine1.0 since qt 5.0 inherits item properties loaded bool name string preloaded bool signals loadedchanged...

QML型別說明 BluetoothService

bluetoothservice importstatement import qtbluetooth 5.2 since qt 5.2 properties deviceaddress string devicename string registered string servicedescri...