QTcpSocket QIODevice::readyRead signal not emitted.
-
Hello guys
I made a client library tpcip in QT, when I import this library into csharp console project, client connects to the server successfully (connected slot is emit) and when the server sends data to the client, the client does not receive the data, does not trigger signal ReadyRead is emitted.. If I make test in the QT console application, then it works!
Git hub repositories:
My library in QT
https://github.com/almirtalktelecom/LibraryTcpIpQt.gitcsharp console project
https://github.com/almirtalktelecom/CrmIntegracao.gitQT Creator version 4.9.0
QT version 5.12.2 (MSVC 2017, 32 bit)Microsoft Visual Studio Professional 2017
Version 15.9.11
VisualStudio.15.Release/15.9.11+28307.586
Microsoft .NET Framework
Version 4.7.03062How to fix this?
Thanks.
Almir
-
Hello
but in the C# anothers signals work fine, eg.: When the client C# send a data to server, the signal bytesWritten is trigger, see on figure console print "bytesWritten 13", and every send data, the message it's printed,
where C# receives the signal bytesWritten. Thank you.
In Qt// Constructor Class
TcpClient::TcpClient(QObject *parent)
: QObject(parent)
, socket(new QTcpSocket(this))
{
.
.
connect(socket, &QIODevice::readyRead, this, &TcpClient::readData);
connect(socket, SIGNAL(bytesWritten(qint64)),this, SLOT(bytesWritten(qint64)));
.
.
}// This signal is trigger to C#
void TcpClient::bytesWritten(qint64 bytes)
{
qDebug() << "bytesWritten " << bytes;
}// But it's not!!!
void TcpClient::readData()
{
ReadDataUser();
} -
I can only quote @VRonin again:
The answer is you don't have an event loop.
Even your example may not work on every O/S or Qt version. Not running the event loop is undefined behavior for most Qt classes.
Regards