[Qt-interest] Subclassing QTcpSocket
Thiago Macieira
thiago at kde.org
Wed Apr 20 15:16:10 CEST 2011
On Wednesday, 20 de April de 2011 14:52:36 Sven Grunewaldt wrote:
> while (hasPendingConnections())
> {
> QTcpSocket *socket = nextPendingConnection();
> QTcpSocketEx *client = qobject_cast<QTcpSocketEx*>(socket);
>
> qDebug() << socket << client;
> }
>
> Sadly this does not seem to work. The output is always
> QTcpSocket(0x22318e0) QObject(0x0)
>
> What am I doing wrong?
You're never creating a QTcpSocketEx object. The object returned from
nextPendingConnection is always a QTcpSocket.
You must override the virtual method in QTcpServer and create your
QTcpSocketEx there.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Senior Product Manager - Nokia, Qt Development Frameworks
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110420/8bbcbda1/attachment.bin
More information about the Qt-interest-old
mailing list