QBluetoothDeviceDiscoveryAgent Class The QBluetoothDeviceDiscoveryAgent class discovers the Bluetooth devices nearby. More...  
 Header:
 #include <QBluetoothDeviceDiscoveryAgent> 


 qmake:
 QT += bluetooth


 Since:
 Qt 5.2


 Inherits:
 QObject



 List of all members, including inherited members  Public Types  
 enum 

Error { NoError, PoweredOffError, InputOutputError, InvalidBluetoothAdapterError, UnsupportedPlatformError, UnknownError }
 
 enum 

InquiryType { GeneralUnlimitedInquiry, LimitedInquiry }
  Properties  
inquiryType : QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069InquiryType   1 property inherited from QObject
  Public Functions  
 

QBluetoothDeviceDiscoveryAgent(QObject *parent = Q_NULLPTR)
 
 

QBluetoothDeviceDiscoveryAgent(const QBluetoothAddress &deviceAdapter, QObject *parent = Q_NULLPTR)
 
 

~QBluetoothDeviceDiscoveryAgent()
 
 QList<QBluetoothDeviceInfo> 

discoveredDevices() const
 
 Error 

error() const
 
 QString 

errorString() const
 
 QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069InquiryType 

inquiryType() const
 
 bool 

isActive() const
 
 void 

setInquiryType(QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069InquiryType type)
   31 public functions inherited from QObject
  Public Slots  
 void 

start()
 
 void 

stop()
   1 public slot inherited from QObject
  Signals  
 void 

canceled()
 
 void 

deviceDiscovered(const QBluetoothDeviceInfo &info)
 
 void 

error(QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069rror error)
 
 void 

finished()
   2 signals inherited from QObject
  Additional Inherited Members  11 static public members inherited from QObject
 9 protected functions inherited from QObject
  Detailed Description The QBluetoothDeviceDiscoveryAgent class discovers the Bluetooth devices nearby. To discover the nearby Bluetooth devices:  create an instance of QBluetoothDeviceDiscoveryAgent, connect to either the deviceDiscovered() or finished() signals, and call start().  void MyClass8b7c:f320:99b9:690f:4595:cd17:293a:c069startDeviceDiscovery()
{

    // Create a discovery agent and connect to its signals
    QBluetoothDeviceDiscoveryAgent *discoveryAgent = new QBluetoothDeviceDiscoveryAgent(this);
    connect(discoveryAgent, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo)),
            this, SLOT(deviceDiscovered(QBluetoothDeviceInfo)));

    // Start a discovery
    discoveryAgent->start();

    //...
}

// In your local slot, read information about the found devices
void MyClass8b7c:f320:99b9:690f:4595:cd17:293a:c069viceDiscovered(const QBluetoothDeviceInfo &device)
{
    qDebug() << "Found new device:" << device.name() << '(' << device.address().toString() << ')';
} To retrieve results asynchronously, connect to the deviceDiscovered() signal. To get a list of all discovered devices, call discoveredDevices() after the finished() signal. This class can be used to discover Classic and Low Energy Bluetooth devices. The individual device type can be determined via the QBluetoothDeviceInfo8b7c:f320:99b9:690f:4595:cd17:293a:c069oreConfigurations() attribute. In most cases the list returned by discoveredDevices() contains both types of devices. However not every platform can detect both types of devices. On platforms with this limitation (for example iOS only suports Low Energy discovery), the discovery process will limit the search to the type which is supported. Note: Since Android 6.0 the ability to detect devices requires ACCESS_COARSE_LOCATION. Member Type Documentation 
enum QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069rror
 Indicates all possible error conditions found during Bluetooth device discovery. 

Constant
Value
Description
 
QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069NoError
0
No error has occurred.
 
QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069PoweredOffError
2
The Bluetooth adaptor is powered off, power it on before doing discovery.
 
QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069InputOutputError
1
Writing or reading from the device resulted in an error.
 
QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069InvalidBluetoothAdapterError
3
The passed local adapter address does not match the physical adapter address of any local Bluetooth device.
 
QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069UnsupportedPlatformError
4
Device discovery is not possible or implemented on the current platform. The error is set in response to a call to start(). An example for such cases are iOS versions below 5.0 which do not support Bluetooth device mvasquez@example.net. This value was introduced by Qt 5.5.
 
QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069UnknownError
100
An unknown error has occurred.
  
enum QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069InquiryType
 This enum describes the inquiry type used while discovering Bluetooth devices. 

Constant
Value
Description
 
QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069GeneralUnlimitedInquiry
0
A general unlimited inquiry. Discovers all visible Bluetooth devices in the local vicinity.
 
QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069LimitedInquiry
1
A limited inquiry discovers devices that are in limited inquiry mode.
  LimitedInquiry is not supported on all platforms. If it is requested on a platform that does not support it, GeneralUnlimitedInquiry will be used instead. Setting LimitedInquiry is useful for multi-player Bluetooth-based games that needs faster communication between the devices. The phone scans for devices in LimitedInquiry and Service Discovery is done on one or two devices to speed up the service scan. After the game has connected to the device it intended to, the device returns to GeneralUnlimitedInquiry.  Property Documentation 
inquiryType : QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069InquiryType
 type of inquiry scan to be used while discovering devices This property affects the type of inquiry scan which is performed while discovering devices. By default, this property is set to GeneralUnlimitedInquiry. Not all platforms support LimitedInquiry. Access functions:  
 QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069InquiryType 

inquiryType() const
 
 void 

setInquiryType(QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069InquiryType type)
  See also InquiryType.  Member Function Documentation 
QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069QBluetoothDeviceDiscoveryAgent(QObject *parent = Q_NULLPTR) Constructs a new Bluetooth device discovery agent with parent parent. 
QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069QBluetoothDeviceDiscoveryAgent(const QBluetoothAddress &deviceAdapter, QObject *parent = Q_NULLPTR) Constructs a new Bluetooth device discovery agent with parent. It uses deviceAdapter for the device search. If deviceAdapter is default constructed the resulting QBluetoothDeviceDiscoveryAgent object will use the local default Bluetooth adapter. If a deviceAdapter is specified that is not a local adapter error() will be set to InvalidBluetoothAdapterError. Therefore it is recommended to test the error flag immediately after using this constructor. See also error(). 
QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069~QBluetoothDeviceDiscoveryAgent() Destructor for ~QBluetoothDeviceDiscoveryAgent() 
[signal] void QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069nceled() This signal is emitted when device discovery is aborted by a call to stop(). 
[signal] void QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069viceDiscovered(const QBluetoothDeviceInfo &info) This signal is emitted when the Bluetooth device described by info is discovered. The signal is emitted as soon as the most important device information has been collected. However, as long as the finished() signal has not been emitted the information collection continues even for already discovered devices. This is particularly true for signal strength information (RSSI). If signal strength information is required it is advisable to retrieve the device information via discoveredDevices() once the discovery has finished. This will yield the most recent RSSI information. See also QBluetoothDeviceInfo8b7c:f320:99b9:690f:4595:cd17:293a:c069rssi(). 
QList<QBluetoothDeviceInfo> QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069iscoveredDevices() const Returns a list of all discovered Bluetooth devices. 
Error QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069rror() const Returns the last error. 
[signal] void QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069rror(QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069rror error) This signal is emitted when an error occurs during Bluetooth device discovery. The error parameter describes the error that occurred. Note: Signal error is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:
connect(bluetoothDeviceDiscoveryAgent, static_cast<void(QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069*)(QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069rror)>(&QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069rror),
    [=](QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069rror error){ /* ... */ }); See also error() and errorString(). 
QString QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069rrorString() const Returns a human-readable description of the last error. 
[signal] void QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069inished() This signal is emitted when Bluetooth device discovery completes. The signal is not going to be emitted if the device discovery finishes with an error. 
bool QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069isActive() const Returns true if the agent is currently discovering Bluetooth devices, otherwise returns false. 
[slot] void QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069start() Starts Bluetooth device discovery, if it is not already started. The deviceDiscovered() signal is emitted as each device is discovered. The finished() signal is emitted once device discovery is complete. 
[slot] void QBluetoothDeviceDiscoveryAgent8b7c:f320:99b9:690f:4595:cd17:293a:c069stop() Stops Bluetooth device discovery. The cancel() signal is emitted once the device discovery is canceled. start() maybe called before the cancel signal is received. Once start() has been called the cancel signal from the prior discovery will be discarded.

    
{'path': 'public/docs/qt~5.6/qbluetoothdevicediscoveryagent.html', 'source': 'DevDocs.IO'}