I'm doing like Qt.That's what you're currently doing.I don't want to limit my users
That's incorrect. readAll() is not virtual.So what can I do ? QIODevice is useless if I cant use this functions...Incorrect, read() is not virtual.
I'm doing like Qt.That's what you're currently doing.I don't want to limit my users
That's incorrect. readAll() is not virtual.So what can I do ? QIODevice is useless if I cant use this functions...Incorrect, read() is not virtual.
What "Qt does" is not always correct. And you're not "doing like Qt". Qt tends to inherit QIODevice rather than its subclasses.
Those methods are already implemented, you don't implement them yourself. Implement readData(), writeData(), bytesAvailable(), waitForBytesWritten(), waitForReadyRead(), possibly canReadLine() and readLineData(). QAbstractSocket uses an internal "socket engine" which does most of the work. If you want to implement your own subclass of QAbstractSocket class, you have to shadow all that because you don't have a working socket engine for your protocol underneath since your QWsSocket is not a real native socket. So you have to rewrite pretty much everything QAbstractSocket does (apart from close(), isSequential() and atEnd()).So what can I do ? QIODevice is useless if I cant use this functions...
The more I look at the source code of QAbstractSocket the more I think this class was simply not meant to be subclassed outside Qt tree (not in this particular case but rather not meant to be subclassed at all). It has hardcoded support for UDP, TCP and SSL and doesn't allow hooking into the code with other implementations. QTcpSocket and QUdpSocket are simply stubs over QAbstractSocket which implements everything from both protocols itself (or actually delegates everything to a subclass of QAbstractSocketEngine such as QNativeSocketEngine).
Bookmarks