Problem with QTcpServer in QT 5.0.1
-
wrote on 14 Feb 2013, 16:36 last edited by
I'v been trying to use QTcpServer in Qt 5.0.1 in a simple QTCoreApplication test program, but somehow 'incomingConnection' never gets called. I've overloaded the 'incomingConnection' in my own TcpServer class (analogue to the Fortune example).
The works fine in Qt 4.8.1 and 4.8.4, but not in 5.01. Did I find a bug? Or am I overlooking something?
The code looks like this:
@
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
myServer server;
return a.exec();
}myServer::myServer()
: QTcpServer()
{
listen(QHostAddress::Any,5678);
}void myServer::incomingConnection(int socketDescriptor)
{
qDebug() << "Incoming!.......";
}
@EDIT: sourounded the code with @-tags
-
wrote on 15 Feb 2013, 00:03 last edited by
If the same code worked in Qt 4 then please file a bug.
-
wrote on 15 Feb 2013, 09:22 last edited by
Check out the "parameter list":http://qt-project.org/doc/qt-5.0/qtnetwork/qtcpserver.html#incomingConnection of the method . It has qintptr not int.
-
wrote on 15 Feb 2013, 09:59 last edited by
hi your code works on qt 5.0.0
-
wrote on 15 Feb 2013, 23:34 last edited by
Apparently I'm having exactly the same problem. I've been working with a code similar to the one posted here for a while now and it's working correctly in Qt 4.8*
Actually it's even working on QT 5.0.0 on Windows.But I just did a fresh install of Fedora Linux 18 64bits, and downloaded the newest QT SDK 5.0.1 and it's not getting to "incomingConnection".
-
wrote on 18 Feb 2013, 15:52 last edited by
Changing the 'int' to 'qintptr' fixes the problem for qt 5.0.1. Unfortunately that is change in the api from previous Qt versions, where it was definitely an 'int', thus breaking existing code.
-
wrote on 18 Feb 2013, 17:50 last edited by
I have verified that the problem gets solved changing the function signature.
Thanks for the help. -
wrote on 28 Jan 2015, 01:09 last edited by
Can someone update the docs regarding the same as I spent almost 3 hrs trying to fix this. Btw changing datatype fixed the problem.
Environment: Qt 5.4 MSVC x64
-
wrote on 28 Jan 2015, 01:09 last edited by
Can someone update the docs regarding the same as I spent almost 3 hrs trying to fix this. Btw changing datatype fixed the problem.
Environment: Qt 5.4 MSVC x64
-
Hi,
Which documentation are you referring to ?
-
Hi,
Which documentation are you referring to ?
-
wrote on 29 Jan 2015, 03:53 last edited by
http://doc-snapshot.qt-project.org/qt5-5.4/qtcpserver.html#incomingConnection
This one. I browsed through the doc but somehow missed the signature as nothing was mentioned regarding the change. I've seen couple of other methods where a note was present saying this particular field has been changed from 4 to 5
-
wrote on 29 Jan 2015, 03:53 last edited by
http://doc-snapshot.qt-project.org/qt5-5.4/qtcpserver.html#incomingConnection
This one. I browsed through the doc but somehow missed the signature as nothing was mentioned regarding the change. I've seen couple of other methods where a note was present saying this particular field has been changed from 4 to 5
-
This change is described in the "C++ API Changes":http://doc.qt.io/qt-5/sourcebreaks.html#changes-to-qt-network page, but I agree that it would be helpful to add a note in the method documentation too.
-
This change is described in the "C++ API Changes":http://doc.qt.io/qt-5/sourcebreaks.html#changes-to-qt-network page, but I agree that it would be helpful to add a note in the method documentation too.