//! [service_discovery]
void MyClass::startServiceDiscovery()
{

    // Create a discovery agent and connect to its signals
    QBluetoothServiceDiscoveryAgent *discoveryAgent = new QBluetoothServiceDiscoveryAgent(this);
    connect(discoveryAgent, SIGNAL(serviceDiscovered(QBluetoothServiceInfo)),
            this, SLOT(serviceDiscovered(QBluetoothServiceInfo)));

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

    //...
}
예제 #2
0
void Discoverer::serviceDiscovery()
{
//! [Service discovery]
    QBluetoothServiceDiscoveryAgent *discoveryAgent = new QBluetoothServiceDiscoveryAgent(this);

    connect(discoveryAgent, SIGNAL(serviceDiscovered(const QBluetoothServiceInfo&)),
            this, SLOT(serviceDiscovered(const QBluetoothServiceInfo&)));

    // Automatically delete agent when service discovery finishes.
    connect(discoveryAgent, SIGNAL(finished()), this, SLOT(deleteLater()));

    discoveryAgent->start();
//! [Service discovery]
}