InvokeMethod on QTcpSocket
-
Hi,
i am trying to invoke "write" on a tcp socket that is in another thread:
@
QTcpSocket* my_socket_in_other_thread = new QTcpSocket();
my_socket_in_other_thread.connect(...);
...QThread* the_thread = new QThread();
my_socket_in_other_thread.moveToThread(the_thread);
the_thread.start();...
QMetaObject::invokeMethod(my_socket_in_other_thread,
"write",
Qt::QueuedConnection,
Q_RETURN_ARG(qint64,ret),
Q_ARG(const QByteArray&,data));
@but this get me the error:
QMetaObject::invokeMethod: No such method QTcpSocket::write(const QByteArray&)
what am i doing wrong?
eddy
-
Hi and welcome to devnet,
You can't call write like that, it's not a slot nor a Q_INVOKABLE method
-
so what is the proper way to send data throug a socket thats in an eventloop of QThread?
Do i need to subclass QThread or make a wrappercalss for QTcpSocket?
-
The worker object paradigm would be appropriate