Qtcpsocket
-
I am using Qt5.14.1 for andriod
m_pTcpSocket->connectToHost(m_sServerIpAddress,m_nServerPort);audiotransmitter.cpp:439:69: error: too few arguments to function call, expected at least 3, have 2
qabstractsocket.h:152:5: note: 'connectToHost' declared herethis error is getting in andriod Qt5.14.1
-
@satyanarayana143 a assume ptcpSocket is not a QTcpSocket, because than connectToHost would have a default parameter as 3rd one
QIODevice::ReadWrite usually.
-
@J-Hilk said in Qtcpsocket:
QIODevice::ReadWrite
i has given like this QIODevice::ReadWrite
but i am getting error openmodeflag cannot convert to openmode
-
@satyanarayana143
more information!What's the definition of connectToHost in
audiotransmitter.h
? -
Qtcpsocket
when i am giving QIODevice::ReadWrite i am getting below error
audiotransmitter.cpp:439:70: error: no viable conversion from 'QIODevice::OpenModeFlag' to 'QIODevice::OpenMode' (aka 'QFlagsQIODevice::OpenModeFlag')
qflags.h:89:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'QIODevice::OpenModeFlag' to 'const QFlagsQIODevice::OpenModeFlag &' for 1st argument
qflags.h:89:7: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'QIODevice::OpenModeFlag' to 'QFlagsQIODevice::OpenModeFlag &&' for 1st argument
qabstractsocket.h:152:80: note: passing argument to parameter 'mode' here -
@satyanarayana143
very strange, shouldn't bee needed, but add#include <QIODevice>
in the file, where you wroteQIODevice::ReadWrite
-
i added
#include <QIODevice>also getting same error
-
@satyanarayana143
May I suggest you actually show the line where you are usingQIODevice::ReadWrite
, and generates the error, rather than just stating you are using it? -
QTcpSocket *m_pTcpSocket=nullptr; m_pTcpSocket = new QTcpSocket(this); m_pTcpSocket->connectToHost(m_sServerIpAddress,m_nServerPort); // In this line i am getting error
error: too few arguments to function call, expected at least 3, have 2
qabstractsocket.h:152:5: note: 'connectToHost' declared herefor andriod Qt5.14.1
-
@satyanarayana143
So if that is in reply to me, that shows me where you are usingQIODevice::ReadWrite
, does it?when i am giving QIODevice::ReadWrite i am getting below error
audiotransmitter.cpp:439:70: error: no viable conversion from 'QIODevice::OpenModeFlag' to 'QIODevice::OpenMode' (aka 'QFlagsQIODevice::OpenModeFlag')
qflags.h:89:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'QIODevice::OpenModeFlag' to 'const QFlagsQIODevice::OpenModeFlag &' for 1st argument
qflags.h:89:7: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'QIODevice::OpenModeFlag' to 'QFlagsQIODevice::OpenModeFlag &&' for 1st argument
qabstractsocket.h:152:80: note: passing argument to parameter 'mode' hereAre you getting this or not? Would you like us to look at it or not?
From https://code.woboq.org/qt5/qtbase/src/network/socket/qabstractsocket.h.html, at lines 152/153, I see
virtual void connectToHost(const QString &hostName, quint16 port, OpenMode mode = ReadWrite, NetworkLayerProtocol protocol = AnyIPProtocol); virtual void connectToHost(const QHostAddress &address, quint16 port, OpenMode mode = ReadWrite);
That means you should not be getting
error: too few arguments to function call, expected at least 3, have 2
You might like to verify what you have at those lines in the
qabstractsocket.h
you have. Is there any chance you have more than one copy of this file somewhere? You might like to copy & paste here the lines you have there, so that we really can see how it could produce that error message?You might like to show us line #439 of
audiotransmitter.cpp
. But I guess that is the
m_pTcpSocket->connectToHost(m_sServerIpAddress,m_nServerPort);
line you are showing us won't compile?