[Interest] Android bluetooth in a thread

Alex Blasche alexander.blasche at qt.io
Thu Jul 26 10:24:39 CEST 2018

I can only speculate as to the nature of the failure. Bluetooth on Android is mostly multi threaded already as the main processing is done in Android main and custom threads already. The resulats are then handed to the thread that owns QBluetoothServiceDiscoveryAgent. From this perspective, it should not really be necessary to shift the Qt classes into another thread.

In any case, during service discovery QBluetoothServiceInfo is only used to tell the user the result of the discovery (aka QBluetoothServiceDiscoveryAgent emits such an object as part of the serviceDiscovered() signal). There is not a single internal QObject::connect that passes QBluetoothServiceInfo as arguments around. Therefore I must conclude that the problem is in your code. The fact the discovery is not working may well be related to how you process the serviceDiscovered() signal in your application which may fail because of the missing metatype registration.

I suggest you enable Bluetooth QLoggingCategory (see official examples for details) and check whether the internal infra really does not find anything. If that works then you have to find the reason in how you interact with the class.


From: Interest <interest-bounces+alexander.blasche=qt.io at qt-project.org> on behalf of maitai <maitai at virtual-winds.org>
Sent: Thursday, 26 July 2018 9:08:00 AM
To: Interest at qt-project.org
Subject: [Interest] Android bluetooth in a thread


Another question about QBluetooth, this time on Android:

If I run a bluetooth "client" class in a thread, discovery fails and I
have this weird message in the console:

QObject::connect: Cannot queue arguments of type 'QBluetoothServiceInfo'
(Make sure 'QBluetoothServiceInfo' is registered using

If I run the exact same class in the main thread, no such message and
everything works OK.

I know that on Mac OS bluetooth must be run in the main thread. Is it
the same for Android? What about other OS (Linux, Windows, iOS) ?

Interest mailing list
Interest at qt-project.org

More information about the Interest mailing list