Qt Bluetooth - no devices discovered.
-
@jsulm
yes. it was stupid of me to block. for now
hclass BT_DEVICE : public QObject { Q_OBJECT public: BT_DEVICE(QObject *parent = nullptr); void BLE_Scan(); public slots: void ScanFinished(); };cpp
BT_DEVICE::BT_DEVICE(QObject *parent) : QObject(parent) { //for debug //connect(&bt_device, &Device::scanFinished, this, &BT_DEVICE::ScanFinished); } void BT_DEVICE::BLE_Scan() { scanning = 1; bt_device.startDeviceDiscovery(); } void BT_DEVICE::ScanFinished() { QVariant devices = bt_device.getDevices(); }Is it OK?
@jenya7 said in Qt Bluetooth - no devices discovered.:
Is it OK?
Why did you comment out the connect?
-
@jenya7 said in Qt Bluetooth - no devices discovered.:
Is it OK?
Why did you comment out the connect?
@jsulm said in Qt Bluetooth - no devices discovered.:
@jenya7 said in Qt Bluetooth - no devices discovered.:
Is it OK?
Why did you comment out the connect?
for debug. I still get the error.
On Windows I get a different error - error: multiple definition of `Device::scanFinished()' in moc_device.cpp.
first defined here device.cpp.
I wonder how can it be - moc file is a generated file after build. -
@jsulm said in Qt Bluetooth - no devices discovered.:
@jenya7 said in Qt Bluetooth - no devices discovered.:
Is it OK?
Why did you comment out the connect?
for debug. I still get the error.
On Windows I get a different error - error: multiple definition of `Device::scanFinished()' in moc_device.cpp.
first defined here device.cpp.
I wonder how can it be - moc file is a generated file after build.@jenya7 said in Qt Bluetooth - no devices discovered.:
I wonder how can it be - moc file is a generated file after build
It is probably a remnant from previos version when scanFinished was declared as signal.
Do a complete rebuild: delete build folder, run qmake and build. -
@jenya7 said in Qt Bluetooth - no devices discovered.:
I wonder how can it be - moc file is a generated file after build
It is probably a remnant from previos version when scanFinished was declared as signal.
Do a complete rebuild: delete build folder, run qmake and build.@jsulm said in Qt Bluetooth - no devices discovered.:
@jenya7 said in Qt Bluetooth - no devices discovered.:
I wonder how can it be - moc file is a generated file after build
It is probably a remnant from previos version when scanFinished was declared as signal.
Do a complete rebuild: delete build folder, run qmake and build.Deleted all from the build folder. Clean. Rebuild. I see new files created. The same problem.
Renamed scanFinished for scanCompleted. Still the same problem. -
@jsulm said in Qt Bluetooth - no devices discovered.:
@jenya7 said in Qt Bluetooth - no devices discovered.:
I wonder how can it be - moc file is a generated file after build
It is probably a remnant from previos version when scanFinished was declared as signal.
Do a complete rebuild: delete build folder, run qmake and build.Deleted all from the build folder. Clean. Rebuild. I see new files created. The same problem.
Renamed scanFinished for scanCompleted. Still the same problem.This post is deleted! -
@jsulm said in Qt Bluetooth - no devices discovered.:
@jenya7 said in Qt Bluetooth - no devices discovered.:
Is it OK?
Why did you comment out the connect?
for debug. I still get the error.
On Windows I get a different error - error: multiple definition of `Device::scanFinished()' in moc_device.cpp.
first defined here device.cpp.
I wonder how can it be - moc file is a generated file after build.@jenya7 said in Qt Bluetooth - no devices discovered.:
On Windows I get a different error - error: multiple definition of `Device::scanFinished()' in moc_device.cpp.
Just realised: this is in Device class.
Please show Device code (header and cpp).
You probably defined scanFinished() in cpp file, you should not do that for signals! -
@jenya7 said in Qt Bluetooth - no devices discovered.:
On Windows I get a different error - error: multiple definition of `Device::scanFinished()' in moc_device.cpp.
Just realised: this is in Device class.
Please show Device code (header and cpp).
You probably defined scanFinished() in cpp file, you should not do that for signals! -
@jenya7 said in Qt Bluetooth - no devices discovered.:
On Linux the same 'vtable' problem
Exact same code?
Do a full rebuild. -
@jenya7 said in Qt Bluetooth - no devices discovered.:
On Linux the same 'vtable' problem
Exact same code?
Do a full rebuild.@jsulm
yes.
I've noticed in device.h at the beginningclass Device: public QObject { Q_OBJECT Q_PROPERTY(QVariant devicesList READ getDevices NOTIFY devicesUpdated) Q_PROPERTY(QVariant servicesList READ getServices NOTIFY servicesUpdated) Q_PROPERTY(QVariant characteristicList READ getCharacteristics NOTIFY characteristicsUpdated) Q_PROPERTY(QString update READ getUpdate WRITE setUpdate NOTIFY updateChanged) Q_PROPERTY(bool useRandomAddress READ isRandomAddress WRITE setRandomAddress NOTIFY randomAddressChanged) Q_PROPERTY(bool state READ state NOTIFY stateChanged) Q_PROPERTY(bool controllerError READ hasControllerError) //and so onthose Q_PROPERTY - do I need it? it's a QML related stuff.
I took the class from a QML project. -
@jsulm
yes.
I've noticed in device.h at the beginningclass Device: public QObject { Q_OBJECT Q_PROPERTY(QVariant devicesList READ getDevices NOTIFY devicesUpdated) Q_PROPERTY(QVariant servicesList READ getServices NOTIFY servicesUpdated) Q_PROPERTY(QVariant characteristicList READ getCharacteristics NOTIFY characteristicsUpdated) Q_PROPERTY(QString update READ getUpdate WRITE setUpdate NOTIFY updateChanged) Q_PROPERTY(bool useRandomAddress READ isRandomAddress WRITE setRandomAddress NOTIFY randomAddressChanged) Q_PROPERTY(bool state READ state NOTIFY stateChanged) Q_PROPERTY(bool controllerError READ hasControllerError) //and so onthose Q_PROPERTY - do I need it? it's a QML related stuff.
I took the class from a QML project.@jenya7 said in Qt Bluetooth - no devices discovered.:
those Q_PROPERTY - do I need it?
If you don't use them then you don't need them.
-
@jenya7 said in Qt Bluetooth - no devices discovered.:
those Q_PROPERTY - do I need it?
If you don't use them then you don't need them.
@jsulm
oops. I did "Run qmake" then "Build" - and it's compiles, no errors.now if I uncomment
connect(&bt_device, &Device::scanFinished, this, &BT_DEVICE::ScanFinished);
I get a run time exceptionThe inferior stopped because it received a signal from the operating system.
in devise.h
signals: void scanFinished();in my h
public slots: void ScanFinished();seems OK.
So this is wrong
Device::Device() { connect(discoveryAgent, &QBluetoothDeviceDiscoveryAgent::finished, this, &Device::scanFinished); }I connect a signal to a signal.
-
This post is deleted!
-
@jsulm
oops. I did "Run qmake" then "Build" - and it's compiles, no errors.now if I uncomment
connect(&bt_device, &Device::scanFinished, this, &BT_DEVICE::ScanFinished);
I get a run time exceptionThe inferior stopped because it received a signal from the operating system.
in devise.h
signals: void scanFinished();in my h
public slots: void ScanFinished();seems OK.
So this is wrong
Device::Device() { connect(discoveryAgent, &QBluetoothDeviceDiscoveryAgent::finished, this, &Device::scanFinished); }I connect a signal to a signal.
@jenya7 said in Qt Bluetooth - no devices discovered.:
I get a run time exception
Then run through debugger to see where and why exactly it is crashing...
I guess it is crashing inside ScanFinished() slot.Connecting a signal to another signal is perfectly valid.