Sending "bluez" error to GUI
-
I am trying to capture "blueZ" library errors to GUI.
I have this connect code and like to at least acknowledge the error.
I have the text = QBluetoothDeviceDiscoveryAgent::errorString(error); wrong.- can I emulate the "agentService" error?
- What is the correct code to get "humanly readable " error to display on GUI?
However, I am not sure which code is actually generating the "blueZ" error.
(last line in debug output)It may not be coming from "agent" code....
-
I am trying to capture "blueZ" library errors to GUI.
I have this connect code and like to at least acknowledge the error.
I have the text = QBluetoothDeviceDiscoveryAgent::errorString(error); wrong.- can I emulate the "agentService" error?
- What is the correct code to get "humanly readable " error to display on GUI?
However, I am not sure which code is actually generating the "blueZ" error.
(last line in debug output)It may not be coming from "agent" code....
@AnneRanch said in Sending "bluez" error to GUI:
can I emulate the "agentService" error?
Hard to say... You could create a
QBluetoothServiceAgentError
, but since it's just an enum, it's not more than an int valuehttps://doc.qt.io/qt-6/qbluetoothservicediscoveryagent.html#Error-enum
What is the correct code to get "humanly readable " error to display on GUI?
Something like this might work (not tested)
connect(agentService, &QBluetoothServiceDiscoveryAgent::errorOccured, [=](){ QString errMsg = agentService->errorString(); ui->chat_7->append(errMsg); }
-
@AnneRanch Could you please learn how to copy and paste the text of your source code and output into the forum. Unsearchable, truncated fragments of screen shots are not nearly as useful.
However, I am not sure which code is actually generating the "blueZ" error.
(last line in debug output)The last line in the debug output is precisely that, debug output (a warning) to stderr from the Qt Bluetooth module.
/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cppThe text of this debug output may not bear any relationship to the text returned by errorString(error).
You can intercept all such (enabled) categorised debug output by installing a global message handler. Doing something useful with that is another thing altogether.
-
@AnneRanch Could you please learn how to copy and paste the text of your source code and output into the forum. Unsearchable, truncated fragments of screen shots are not nearly as useful.
However, I am not sure which code is actually generating the "blueZ" error.
(last line in debug output)The last line in the debug output is precisely that, debug output (a warning) to stderr from the Qt Bluetooth module.
/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cppThe text of this debug output may not bear any relationship to the text returned by errorString(error).
You can intercept all such (enabled) categorised debug output by installing a global message handler. Doing something useful with that is another thing altogether.
I have an opportunity to verify the "copy from buez to GUI"... my latest OS update deleted bluez !!
So - here is my attempt to do that and it is failing even trying to just qDebug a test errMsg.....
I am not asking for RTFM - I need somebody to help me to actually WRITE the correct code.
localAdapters = QBluetoothLocalDevice::allDevices(); connect(localAdapters,&QBluetoothLocalDevice::error, [=](){ QString errMsg = "TEST "; qDebug() << errMsg; } );
...and the error is....
/mnt/07b7c3f8-0efb-45ab-8df8-2a468771de1f/PROJECTS/BT_JAN18_/CCC_SOURCE/btchat/chat.cpp:118: error: no matching member function for call to 'connect' chat.cpp:118:13: error: no matching member function for call to 'connect' connect(localAdapters,&QBluetoothLocalDevice::error, ^~~~~~~ /home/nov25-1/Qt/Nov26/5.15.2/gcc_64/include/QtCore/qobject.h:314:13: note: candidate function [with Func1 = void (QBluetoothLocalDevice::*)(QBluetoothLocalDevice::Error), Func2 = (lambda at chat.cpp:119:21)] not viable: no known conversion from 'QList<QBluetoothHostInfo>' to 'const typename QtPrivate::FunctionPointer<void (QBluetoothLocalDevice::*)(Error)>::Object *' (aka 'const QBluetoothLocalDevice *') for 1st argument connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, Func2 slot) ^ /home/nov25-1/Qt/Nov26/5.15.2/gcc_64/include/QtCore/qobject.h:481:41: note: candidate function not viable: no known conversion from 'QList<QBluetoothHostInfo>' to 'const QObject *' for 1st argument inline QMetaObject::Connection QObject::connect(const QObject *asender, const char *asignal, ^ /home/nov25-1/Qt/Nov26/5.15.2/gcc_64/include/QtCore/qobject.h:274:13: note: candidate template ignored: requirement 'int(QtPrivate::FunctionPointer<(lambda at chat.cpp:119:21)>::ArgumentCount) >= 0' was not satisfied [with Func1 = void (QBluetoothLocalDevice::*)(QBluetoothLocalDevice::Error), Func2 = (lambda at chat.cpp:119:21)] connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, Func2 slot) ^ /home/nov25-1/Qt/Nov26/5.15.2/gcc_64/include/QtCore/qobject.h:222:36: note: candidate function not viable: requires at least 4 arguments, but 3 were provided static QMetaObject::Connection connect(const QObject *sender, const char *signal, ^ /home/nov25-1/Qt/Nov26/5.15.2/gcc_64/include/QtCore/qobject.h:225:36: note: candidate function not viable: requires at least 4 arguments, but 3 were provided static QMetaObject::Connection connect(const QObject *sender, const QMetaMethod &signal, ^ /home/nov25-1/Qt/Nov26/5.15.2/gcc_64/include/QtCore/qobject.h:242:43: note: candidate function template not viable: requires at least 4 arguments, but 3 were provided static inline QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, ^ /home/nov25-1/Qt/Nov26/5.15.2/gcc_64/include/QtCore/qobject.h:283:13: note: candidate function template not viable: requires at least 4 arguments, but 3 were provided connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, const QObject *context, Func2 slot, ^ /home/nov25-1/Qt/Nov26/5.15.2/gcc_64/include/QtCore/qobject.h:322:13: note: candidate function template not viable: requires at least 4 arguments, but 3 were provided connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, const QObject *context, Func2 slot, ^
-
localAdapters is a QList of QBluetoothHostInfo . Neither QList nor QBluetoothHostInfo is a QObject so connect() will not work, esp. since the function/signal you're trying to connect is of type QBluetoothLocalDevice::error
-
localAdapters is a QList of QBluetoothHostInfo . Neither QList nor QBluetoothHostInfo is a QObject so connect() will not work, esp. since the function/signal you're trying to connect is of type QBluetoothLocalDevice::error
@Christian-Ehrlicher ...here is the error "created " by updated OS
"int Chat::AutoConnect() \n @line 363"
Cannot find a running Bluez. Please check the Bluez installation.
ASSERT failure in QList<T>::at: "index out of range", file /home/nov25-1/Qt/Nov26/5.15.2/gcc_64/include/QtCore/qlist.h, line 571
10:55:50: /mnt/07b7c3f8-0efb-45ab-8df8-2a468771de1f/PROJECTS/BT_JAN18_/CCC_SOURCE/btchat/btchat crashed.are you saying I cannot display this particular error on GUI ?
The "missing bluez' is causing the "index out of range " - the app won't run at all.
I am reinstalling "bluez".... -
Don't see what this has to do with your connect() problem above but when you get an assertion you will use a debugger to see where it come from (as already told you many times)