Unsolved calling function with functions
-
if I have a class with function like this
void test::listen()
{
QTcpServer::listen(QHostAddress::Any,1234);
}how can I access QTcpServer::listen() from another file? something like this?
test *tt = new test();
tt->lisen()::QTcpServer::listen() ??
-
Hi,
Are you aware that the listen function of QTcpServer is not a static method ?
-
-
@s002wjh
You asked this and @jsulm answered you at https://forum.qt.io/topic/110393/check-port-in-use/8@jsulm said in check port in use:
@s002wjh said in check port in use:
can I do this without creating new tcpserver etc?
No, because listen() is not static
You need to understand
static
and thatQTcpServer::listen()
is not static and really is going to require you to create an instance ofQTcpServer
in order to call it :) -
Hi
You are a bit off.
You need to have an instance and it has to be a member.class test {
...
QTcpServer server;//instance
}void test::listen()
{
server.listen(QHostAddress::Any,1234); // use the instance, listen cannot be used as static method
}test *tt = new test();
tt->listen(); -
@s002wjh said in calling function with functions:
how can I access QTcpServer::listen() from another file?
I really don't get what you want to do.
To call QTcpServer::listen() in another file you do it in exact same way you do it in test (but create an QTcpServer instance as listen() is not static as I already told you). You really should read a book about C++.