Solved Signal Slot not working
-
Hi
check if connects fails
Q_ASSUME ( connect(m_bluetoothSocket, SIGNAL(readyReadn()), this, SLOT(readSocket())) );
Q_ASSUME ( connect(m_bluetoothSocket, SIGNAL(connected()), this, SLOT(connected())));
Q_ASSUME ( connect(m_bluetoothSocket, SIGNAL(disconnected()), this, SIGNAL(disconnected()))); -
@mrjj said in Signal Slot not working:
Q_ASSUME
No difference.
Connect fails if i change the names of slot. Hence correct connections are being done.
On server side I am getting a notification that a client is connected.
-
@Avtansh-Sharma
Do you run it in a thread ?
If not, maybe your while loop strangulate the event loop.Anyway, i think you will need to use the debugger to find the cause of "not working"
-
I created a custom signal slot . It is working in this class.
No I am not using a thread
-
Ok so what exactly is not working ?
-
The signal slot mechanism of QBluetooth
Socket is not working
readSocket,connected are never getting called even after server says a client has made a connection -
Ok, might be a bug or something im not seeing in the code.
You can check https://bugreports.qt.ioIs other signals being sent ? like disconnected ?
make sure all connects are using Q_ASSUME so its not something trivial.
There is nothing that spring to mind. Maybe others can spot something.
-
@mrjj Thanks for help.
I remember you were saying something about thread can you please explain int detail. I will be using thread anyway in future. Maybe it will work in thread.
-
@Avtansh-Sharma said in Signal Slot not working:
connect(m_bluetoothSocket, SIGNAL(readyReadn())
Typo? should be
connect(m_bluetoothSocket, SIGNAL(readyRead())
or, better, using Qt5 syntax:connect(m_bluetoothSocket,&QBluetoothSocket::readyRead,this,&DeviceData::readSocket);
-
@Avtansh-Sharma
Hi
Using a thread will most likely not make any difference with the current issue but
when you use signals from inside a thread , it's sometimes necessary to add Qt::QueuedConnection
to the connect statement.
https://woboq.com/blog/how-qt-signals-slots-work-part3-queuedconnection.html