Skip to content

Class QfBluetoothDeviceModel

ClassList > QfBluetoothDeviceModel

More...

  • #include <qfbluetoothdevicemodel.h>

Inherits the following classes: QAbstractListModel

Public Types

Type Name
enum BluetoothDeviceRoles
The roles provided by this model.
enum ScanningStatus
The status telling the result of the scanning.

Public Properties

Type Name
property qsizetype lastDiscoveredCount
property QString lastError
property ScanningStatus scanningStatus

Public Signals

Type Name
signal void lastDiscoveredCountChanged
signal void lastErrorChanged (QString lastError)
signal void scanningStatusChanged (QfBluetoothDeviceModel::ScanningStatus scanningStatus)

Public Functions

Type Name
QfBluetoothDeviceModel (QObject * parent=nullptr)
Q_INVOKABLE int addDevice (const QString & name, const QString & address)
QVariant data (const QModelIndex & index, int role=Qt::DisplayRole) override const
QString deviceAddress (const QBluetoothDeviceInfo & info) const
Q_INVOKABLE int findIndexFromAddress (const QString & address) const
qsizetype lastDiscoveredCount () const
QString lastError () const
QHash< int, QByteArray > roleNames () override const
int rowCount (const QModelIndex & parent=QModelIndex()) override const
ScanningStatus scanningStatus () const
Q_INVOKABLE void startDeviceDiscovery ()
Q_INVOKABLE void stopDeviceDiscovery ()
~QfBluetoothDeviceModel ()

Detailed Description

A model that provides all paired bluetooth devices name/address that are accessible over the serial port.

Public Types Documentation

enum BluetoothDeviceRoles

The roles provided by this model.

enum QfBluetoothDeviceModel::BluetoothDeviceRoles {
    DeviceAddressRole = Qt::UserRole + 1,
    DeviceNameRole,
    DeviceClassicSupportRole,
    DeviceLowEnergySupportRole,
    DeviceLowEnergyByDefaultRole
};


enum ScanningStatus

The status telling the result of the scanning.

enum QfBluetoothDeviceModel::ScanningStatus {
    Discovering,
    Succeeded,
    Failed,
    Canceled,
    NoStatus
};


Public Properties Documentation

property lastDiscoveredCount [1/2]

qsizetype QfBluetoothDeviceModel::lastDiscoveredCount;

property lastError [1/2]

QString QfBluetoothDeviceModel::lastError;

property scanningStatus [1/2]

ScanningStatus QfBluetoothDeviceModel::scanningStatus;

Public Signals Documentation

signal lastDiscoveredCountChanged

void QfBluetoothDeviceModel::lastDiscoveredCountChanged;

signal lastErrorChanged

void QfBluetoothDeviceModel::lastErrorChanged;

signal scanningStatusChanged

void QfBluetoothDeviceModel::scanningStatusChanged;

Public Functions Documentation

function QfBluetoothDeviceModel

explicit QfBluetoothDeviceModel::QfBluetoothDeviceModel (
    QObject * parent=nullptr
) 

function addDevice

Q_INVOKABLE int QfBluetoothDeviceModel::addDevice (
    const QString & name,
    const QString & address
) 

Adds a Bluetooth device if not already in the model

Parameters:

  • name friendly device name used as identifier in the user interface
  • address Bluetooth address of the device

Returns:

returns index of the Bluetooth device


function data

QVariant QfBluetoothDeviceModel::data (
    const QModelIndex & index,
    int role=Qt::DisplayRole
) override const

function deviceAddress

QString QfBluetoothDeviceModel::deviceAddress (
    const QBluetoothDeviceInfo & info
) const

function findIndexFromAddress

Q_INVOKABLE int QfBluetoothDeviceModel::findIndexFromAddress (
    const QString & address
) const

Returns the row index for a given Bluetooth device address


function lastDiscoveredCount [2/2]

inline qsizetype QfBluetoothDeviceModel::lastDiscoveredCount () const

function lastError [2/2]

inline QString QfBluetoothDeviceModel::lastError () const

function roleNames

QHash< int, QByteArray > QfBluetoothDeviceModel::roleNames () override const

function rowCount

int QfBluetoothDeviceModel::rowCount (
    const QModelIndex & parent=QModelIndex()
) override const

function scanningStatus [2/2]

inline ScanningStatus QfBluetoothDeviceModel::scanningStatus () const

function startDeviceDiscovery

Q_INVOKABLE void QfBluetoothDeviceModel::startDeviceDiscovery () 

Starts a scan to discover nearby Bluetooth devices, sequentially going through a fast scan then a full, deeper scan for devices.


function stopDeviceDiscovery

Q_INVOKABLE void QfBluetoothDeviceModel::stopDeviceDiscovery () 

Stops any ongoing scan to discover nearby Bluetooth devices.


function ~QfBluetoothDeviceModel

QfBluetoothDeviceModel::~QfBluetoothDeviceModel () 


The documentation for this class was generated from the following file src/core/positioning/qfbluetoothdevicemodel.h