I have a two classes derived from QThread
First class emits a signal to the second class when an event occurs. I connected these signal and slot with queud connection explicitly. Second class try to write to a tcp socket created in the run block of the second class. but it gives the error "QSocketNotifier can not enable from an other thread." I coul not understand why this happen.
Code is beriefly below :
connect(firstClass,SIGNAL(send(int )),secondClass,SLOT(response(int )),Qt::QueuedConnection);
firstClass::emitSignal()
{
emit send(1);
}
secondClass::run()
{
....
...
}
secondClass::response(int a_data)
{
m_socket->write(".....");
}
connect(firstClass,SIGNAL(send(int )),secondClass,SLOT(response(int )),Qt::QueuedConnection);
firstClass::emitSignal()
{
emit send(1);
}
secondClass::run()
{
m_socket = new QTcpSocket();
....
...
}
secondClass::response(int a_data)
{
m_socket->write(".....");
}
To copy to clipboard, switch view to plain text mode
Bookmarks