BluetoothDiscoveryModel QML Type

Enables searching for the Bluetooth devices and services in range. 更多...

导入语句: import QtBluetooth 5.2
Since: Qt 5.2

特性

信号

详细描述

BluetoothDiscoveryModel provides a model of connectable services. The contents of the model can be filtered by UUID allowing discovery to be limited to a single service such as a game.

The model roles provided by BluetoothDiscoveryModel are service , name , remoteAddress and deviceName . The meaning of the roles changes based on the current discoveryMode .

Model role Device Discovery Service Discovery
name The device's name and address. The service name and the name of the device offering the service. If the device name is empty the devices address will be used.
deviceName The name of the device. The name of the device offering the service.
service The role is undefined in this mode. BluetoothService object describing the discovered service.
remoteAddress The address of the found device. The address of the device offering the service.

另请参阅 QBluetoothServiceDiscoveryAgent .

特性文档编制

discoveryMode : enumeration

Sets the discovery mode. The discovery mode has to be set before the discovery is started

特性 描述
BluetoothDiscoveryModel.FullServiceDiscovery Starts a full discovery of all services of all devices in range.
BluetoothDiscoveryModel.MinimalServiceDiscovery (Default) Starts a minimal discovery of all services of all devices in range. A minimal discovery is faster but only guarantees the device and UUID information to be correct.
BluetoothDiscoveryModel.DeviceDiscovery Discovers only devices in range. The service role will be 0 for any model item.

error : enumeration

This property holds the last error reported during discovery.

特性 描述
BluetoothDiscoveryModel.NoError 没有出现错误。
BluetoothDiscoveryModel.InputOutputError An IO failure occurred during device discovery
BluetoothDiscoveryModel.PoweredOffError The bluetooth device is not powered on.
BluetoothDiscoveryModel.InvalidBluetoothAdapterError There is no default Bluetooth device to perform the service discovery. The model always uses the local default adapter. Specifying a default adapter is not possible. If that's required, QBluetoothServiceDiscoveryAgent should be directly used. This value was introduced by Qt 5.4.
BluetoothDiscoveryModel.UnknownError 出现未知错误。

This property is read-only.


remoteAddress : string

This property holds an optional bluetooth address for a remote bluetooth device. Only services on this remote device will be discovered. It has no effect if an invalid bluetooth address was set or if the property was set after the discovery was started.

The property is ignored if device discovery is selected.


running : bool

This property starts or stops discovery. A restart of the discovery process requires setting this property to false and subsequently to true 再次。


uuidFilter : string

This property holds an optional UUID filter. A UUID can be used to return only matching services. 16 bit, 32 bit or 128 bit UUIDs can be used. The string format is same as the format of QUuid .

另请参阅 QBluetoothUuid and QUuid .


信号文档编制

deviceDiscovered ( string device )

This signal is emitted when a new device is discovered. device contains the Bluetooth address of the discovered device.

相应处理程序是 onDeviceDiscovered .


serviceDiscovered ( BluetoothService service )

This signal is emitted when a new service is discovered. The service parameter contains the service details.

相应处理程序是 onServiceDiscovered .

另请参阅 BluetoothService .