Find bluetooth device
-
Hi!
I use Windows 10, Qt 6.2.
I wont find bluetooth device, but cand do this. Programm not see devices.#ifndef APPCORE_H #define APPCORE_H #include <QObject> #include <QDebug> #include <QJSEngine> #include <QQmlEngine> #include <QJsonDocument> #include <QJsonObject> #include <QJsonArray> #include <QJsonValue> #include <QBluetoothLocalDevice> #include <QBluetoothDeviceDiscoveryAgent> #include <QBluetoothDeviceInfo> #include <QBluetoothSocket> class AppCore: public QObject { Q_OBJECT public: AppCore(); ~AppCore(); public slots: void startAppCore(); void getAvailableBluetooth(); private: QBluetoothDeviceDiscoveryAgent * m_bluetoothAgent = new QBluetoothDeviceDiscoveryAgent; QBluetoothSocket *m_bluetoothSocket = new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol); private slots: void onBluetoothDeviceDiscovered(const QBluetoothDeviceInfo &info); }; static QObject *singeltonProvider(QQmlEngine *engine, QJSEngine *scriptEngine) { Q_UNUSED(engine); Q_UNUSED(scriptEngine); AppCore *appCore=new AppCore(); return appCore; } #endif // APPCORE_H
#include "appcore.h" AppCore::AppCore() { connect(m_bluetoothAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered, this, &AppCore::onBluetoothDeviceDiscovered); m_bluetoothAgent->start(); } AppCore::~AppCore() { } void AppCore::startAppCore() { } void AppCore::getAvailableBluetooth() { } void AppCore::onBluetoothDeviceDiscovered(const QBluetoothDeviceInfo &info) { qDebug()<<"11111111111111111111111"; qDebug()<<info.name()<<info.address(); }
-
Hi!
I use Windows 10, Qt 6.2.
I wont find bluetooth device, but cand do this. Programm not see devices.#ifndef APPCORE_H #define APPCORE_H #include <QObject> #include <QDebug> #include <QJSEngine> #include <QQmlEngine> #include <QJsonDocument> #include <QJsonObject> #include <QJsonArray> #include <QJsonValue> #include <QBluetoothLocalDevice> #include <QBluetoothDeviceDiscoveryAgent> #include <QBluetoothDeviceInfo> #include <QBluetoothSocket> class AppCore: public QObject { Q_OBJECT public: AppCore(); ~AppCore(); public slots: void startAppCore(); void getAvailableBluetooth(); private: QBluetoothDeviceDiscoveryAgent * m_bluetoothAgent = new QBluetoothDeviceDiscoveryAgent; QBluetoothSocket *m_bluetoothSocket = new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol); private slots: void onBluetoothDeviceDiscovered(const QBluetoothDeviceInfo &info); }; static QObject *singeltonProvider(QQmlEngine *engine, QJSEngine *scriptEngine) { Q_UNUSED(engine); Q_UNUSED(scriptEngine); AppCore *appCore=new AppCore(); return appCore; } #endif // APPCORE_H
#include "appcore.h" AppCore::AppCore() { connect(m_bluetoothAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered, this, &AppCore::onBluetoothDeviceDiscovered); m_bluetoothAgent->start(); } AppCore::~AppCore() { } void AppCore::startAppCore() { } void AppCore::getAvailableBluetooth() { } void AppCore::onBluetoothDeviceDiscovered(const QBluetoothDeviceInfo &info) { qDebug()<<"11111111111111111111111"; qDebug()<<info.name()<<info.address(); }
-
Your code as shown has no call to free function
singeltonProvider()
. Does it even get called? -
You might check QBluetoothDeviceDiscoveryAgent::DiscoveryMethods QBluetoothDeviceDiscoveryAgent::supportedDiscoveryMethods() to make sure that it can do any BT discovery at all.
-
You say you are Windows but do not mention compiler? From Changes to Qt Bluetooth:
Win32 backend has been removed. There will not be a working Bluetooth backend when Qt is built with mingw.
?
-
-
@JonB said in Find bluetooth device:
I use singeltonProvider() in main.cpp
I use MinGw 64 bit qt 6.2.3
QBluetoothDeviceDiscoveryAgent::supportedDiscoveryMethods() returnQFlags<QBluetoothDeviceDiscoveryAgent::DiscoveryMethod>(NoMethod)
And programm said
qt.bluetooth: Dummy backend running. Qt Bluetooth module is non-functional.
-
@JonB said in Find bluetooth device:
I use singeltonProvider() in main.cpp
I use MinGw 64 bit qt 6.2.3
QBluetoothDeviceDiscoveryAgent::supportedDiscoveryMethods() returnQFlags<QBluetoothDeviceDiscoveryAgent::DiscoveryMethod>(NoMethod)
And programm said
qt.bluetooth: Dummy backend running. Qt Bluetooth module is non-functional.