QTcpServer: No such file or directory (Qt 4, SuSe 10)
I'm trying to create a QTcpServer inside a QThread. I get the error "QTcpServer: No such file or directory" error.
The include path is not added to the Makefile when running the following:
qmake -project
qmake
Has anyone seen this problem, if so, how would you go about solving it? Thanks in advanced.
Re: QTcpServer: No such file or directory (Qt 4, SuSe 10)
Add "QT += network" to your .pro file.
Re: QTcpServer: No such file or directory (Qt 4, SuSe 10)
Thanks a lot for the help. This fixed my problem with the missing Include and Library.
I am able to compile my code but when I run it I get the following error:
ASSERT failure in QObject::QObject(): "Cannot create children for a parent that is in a different thread."
The code is the following:
Code:
mythread::mythread()
{
}
mythread::run()
{
while(isRunning())
{
tcpServ->listen();
}
exec();
}
One more question. Since this is a different problem/question do I continue in this thread or is it best placed as a new thread?
Thanks for the help.
Re: QTcpServer: No such file or directory (Qt 4, SuSe 10)
Quote:
Originally Posted by freak
ASSERT failure in QObject::QObject(): "Cannot create children for a parent that is in a different thread."
When the constructor is executed that new thread doesn't exist yet (not mentioning that mythread object lives in a thread that created it). If you create an object in the constructor it will live in a wrong thread. Therefore you should create QTcpServer in mythread::run() (without a parent):
Code:
mythread::run()
{
while(isRunning())
{
tcpServ->listen();
}
exec();
}
http://doc.trolltech.com/4.1/threads.html
Quote:
Since this is a different problem/question do I continue in this thread or is it best placed as a new thread?
Next time, please, start a new thread.