Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QBluetoothDeviceDiscoveryAgent Class Reference

The QBluetoothDeviceDiscoveryAgent class provides an API for discovering nearby Bluetooth devices. More...

 #include <QBluetoothDeviceDiscoveryAgent>

Inherits: QObject.

This class was introduced in Qt Mobility 1.2.

Public Types

enum Error { NoError, PoweredOff, IOFailure, UnknownError }
enum InquiryType { GeneralUnlimitedInquiry, LimitedInquiry }

Properties

  • inquiryType : QBluetoothDeviceDiscoveryAgent::InquiryType
  • 1 property inherited from QObject

Public Functions

QBluetoothDeviceDiscoveryAgent ( QObject * parent = 0 )
~QBluetoothDeviceDiscoveryAgent ()
QList<QBluetoothDeviceInfo> discoveredDevices () const
Error error () const
QString errorString () const
QBluetoothDeviceDiscoveryAgent::InquiryType inquiryType () const
bool isActive () const
void setInquiryType ( QBluetoothDeviceDiscoveryAgent::InquiryType type )
  • 29 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 ( QBluetoothDeviceDiscoveryAgent::Error error )
void finished ()

Additional Inherited Members

  • 1 public variable inherited from QObject
  • 4 static public members inherited from QObject
  • 7 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

The QBluetoothDeviceDiscoveryAgent class provides an API for discovering nearby Bluetooth devices.

To discovery nearby Bluetooth devices create an instance of QBluetoothDeviceDiscoveryAgent, connect to either the deviceDiscovered() or finished() signals and call start().

     QBluetoothDeviceDiscoveryAgent *discoveryAgent = new QBluetoothDeviceDiscoveryAgent(this);

     connect(discoveryAgent, SIGNAL(deviceDiscovered(const QBluetoothDeviceInfo&)),
             this, SLOT(deviceDiscovered(const QBluetoothDeviceInfo&)));

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

     discoveryAgent->start();

To retrieve results asynchronously connect to the deviceDiscovered() signal. To get a list of all discovered devices call discoveredDevices() after the finished() signal is emitted.

Member Type Documentation

enum QBluetoothDeviceDiscoveryAgent::Error

Indicates all possible error conditions found during Bluetooth device discovery.

ConstantValueDescription
QBluetoothDeviceDiscoveryAgent::NoError0No error has occurred.
QBluetoothDeviceDiscoveryAgent::PoweredOff2Bluetooth adaptor is powered off, power it on before doing discovery.
QBluetoothDeviceDiscoveryAgent::IOFailure1Writing or reading from device resulted in an error.
QBluetoothDeviceDiscoveryAgent::UnknownError100An unknown error has occurred.

enum QBluetoothDeviceDiscoveryAgent::InquiryType

This enum describes the inquiry type used when discovering Bluetooth devices.

ConstantValueDescription
QBluetoothDeviceDiscoveryAgent::GeneralUnlimitedInquiry0A general unlimited inquiry. Discovers all visible Bluetooth devices in the local vicinity.
QBluetoothDeviceDiscoveryAgent::LimitedInquiry1A limited inquiry. Only discovers devices that are in limited inquiry mode. Not all platforms support limited inquiry. If limited inquiry is requested on a platform that does not support it general unlimited inquiry we be used instead. Setting LimitedInquiry is useful for 2 games that wish to find each other quickly. The phone scans for devices in LimitedInquiry and Service Discovery is only done on one or two devices speeding up the service scan. After the game has connected the device returns to GeneralUnilimitedInquiry

Property Documentation

inquiryType : QBluetoothDeviceDiscoveryAgent::InquiryType

This property holds type of inquiry scan to use when discovering devices.

This property affects the type of inquiry scan which is performed when discovering devices.

By default, this property is set to GeneralUnlimitedInquiry.

Not all platforms support LimitedInquiry.

Access functions:

QBluetoothDeviceDiscoveryAgent::InquiryType inquiryType () const
void setInquiryType ( QBluetoothDeviceDiscoveryAgent::InquiryType type )

See also InquiryType.

Member Function Documentation

QBluetoothDeviceDiscoveryAgent::QBluetoothDeviceDiscoveryAgent ( QObject * parent = 0 )

Constructs a new Bluetooth device discovery agent with parent parent.

QBluetoothDeviceDiscoveryAgent::~QBluetoothDeviceDiscoveryAgent ()

Destructor for ~QBluetoothDeviceDiscoveryAgent()

void QBluetoothDeviceDiscoveryAgent::canceled () [signal]

This signal is emitted when device discovery is aborted by a call to stop().

void QBluetoothDeviceDiscoveryAgent::deviceDiscovered ( const QBluetoothDeviceInfo & info ) [signal]

This signal is emitted when the Bluetooth device described by info is discovered.

QList<QBluetoothDeviceInfo> QBluetoothDeviceDiscoveryAgent::discoveredDevices () const

Returns a list of all discovered Bluetooth devices.

Error QBluetoothDeviceDiscoveryAgent::error () const

Returns the last error which has occurred.

void QBluetoothDeviceDiscoveryAgent::error ( QBluetoothDeviceDiscoveryAgent::Error error ) [signal]

This signal is emitted when an error occurs during Bluetooth device discovery.

See also error() and errorString().

QString QBluetoothDeviceDiscoveryAgent::errorString () const

Returns a human-readable description of the last error that occurred.

void QBluetoothDeviceDiscoveryAgent::finished () [signal]

This signal is emitted when Bluetooth device discovery completes.

bool QBluetoothDeviceDiscoveryAgent::isActive () const

Returns true if the agent is currently discovering Bluetooth devices, other returns false.

void QBluetoothDeviceDiscoveryAgent::start () [slot]

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.

void QBluetoothDeviceDiscoveryAgent::stop () [slot]

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 silently discarded.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 82
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 6
Page suivante

Le blog Digia au hasard

Logo

Déploiement d'applications Qt Commercial sur les tablettes Windows 8

Le blog Digia est l'endroit privilégié pour la communication sur l'édition commerciale de Qt, où des réponses publiques sont apportées aux questions les plus posées au support. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt qtmobility-1.2
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web