[solved] linking error when setting up signals and slots within a thread
-
wrote on 12 Jan 2014, 01:20 last edited by
Hello,
I have a tcpServer class calling a thread when there is an incoming connection; The thread in-turn creates a tcpSocket and waits for data. I want the data to be analyzed/plotted. I tried setting up a signal on readyread connection to a slot defined in the thread.
@void listenWriteThread::run()
{
QTcpSocket tcpSocket;
if (!tcpSocket.setSocketDescriptor(socketDescriptor)) {
emit error(tcpSocket.error());
return;
}connect(tcpSocket,SIGNAL(readyRead()),this,SLOT(analyzeThis()));@
I get a No-matching function error:
D:\kpks\software\tcpComm\listenWriteThread.cpp:18: error: no matching function for call to 'listenWriteThread::connect(QTcpSocket&, const char*, listenWriteThread* const, const char*)'
connect(tcpSocket,SIGNAL(tcpSocket.readyRead()),this,SLOT(analyzeThis()));What am I doing wrong here?
Thanks and Regards,
kpks^
-
wrote on 12 Jan 2014, 02:05 last edited by
Sorry! That was atrocious doubt! I just forgot to make tcpSocket a pointer :(
I changed my thread definition to have socket as a pointer:
@class listenWriteThread : public QThread
{
Q_OBJECTpublic:
listenWriteThread(int socketDescriptor, const QString &fortune, QObject *parent);void run();
public slots:
void analyzeThis();
signals:
void error(QTcpSocket::SocketError socketError);private:
QTcpSocket* tcpSocket;
int socketDescriptor;
QString text;
};@ -
wrote on 12 Jan 2014, 02:06 last edited by
I have a new problem though, the connection is fine and my C client is sending data every 100ms but qt does nothing! My qt application is tcpComm.exe
Then I get a windows error saying
"the tcpCOmm.exe has encountered a problem and needs to close "Should I make this a separate thread?
-
Hi,
Did you initialize tcpSocket properly ? Did you update your run function ?
2/4