How do I call the C function “connect” with out invoking the signal slots process “connect”.
-
If you want to call a function in another namespace (and your connect() for socket is in the global namespace) you should tell the compiler this -->
::connect()
. -
It’s C code so namespaces do not exist, it’s strictly call by function names only.
-
@DaShubWubDub said in How do I call the C function “connect” with out invoking the signal slots process “connect”.:
It’s C code so namespaces do not exist, it’s strictly call by function names only.
You're using a c function in c++ so you have to follow the c++ rules... but you can ignore my post and maybe you will find the answer later from someone else.
-
@DaShubWubDub
In C code you cannot call C++ code, such asQObject::connect()
.connect()
will be the C library one and that is that.In C++
QObject::connect()
will call Qt's function.::connect()
would allow you to call the C libraryconnect()
.Like @Christian-Ehrlicher says.
-
So somewhere by default Qt uses, use name space qobject. How would I disable that convenience?
C++ has well defined scope rules, and Qt does not change this. If you call
connect()
inside a SomeClass derived from QObject, then you will execute SomeClass::connect() in preference to any otherconnect()
that may be accessible in another scope. If you want to execute the connect() function from global scope then you need to specify that scope, i.e.::connect()
.Given that you are adamant that calling
::connect()
does not fix you issue, perhaps you could post the code that generates the error message so we can stop guessing what you are actually doing and point out exactly what is wrong.BTW: QTcpSocket should be able to connect to any TCP services. I suspect the problem is actually elsewhere and you are wasting time looking here.
-
@DaShubWubDub said in How do I call the C function “connect” with out invoking the signal slots process “connect”.:
you can create a signal slot connection by calling connect(object, signal(), class, slot());
Exactly as @ChrisW67 and @Christian-Ehrlicher and I have said. The only place you can write
connect()
like that and have it refer toQObject::connect()
is if you are inside a class which inherits fromQObject
. And if you are in that situation you have to write::connect()
to refer to C runtime library'sconnect()
. That is what you must do.::connect()
won't work in truly C code, but then if you are inside a class derived fromQObject
you must be in C++ rather than C anyway. -
Christian Ehrlicher Lifetime Qt Championreplied to DaShubWubDub on last edited by Christian Ehrlicher
@DaShubWubDub said in How do I call the C function “connect” with out invoking the signal slots process “connect”.:
. How would I disable that convenience?
Maybe by not ignoring my answer instead asking the same question over and then getting exactly the same answer which you simply ignore again?
I'm desperately missing the downvote button...
-
@Christian-Ehrlicher all you had to say is that it’s not possible. Down voting is for Reddit games, it’s not a proveable working tool to help anyone.
-
Christian Ehrlicher Lifetime Qt Championreplied to DaShubWubDub on last edited by Christian Ehrlicher
@DaShubWubDub said in How do I call the C function “connect” with out invoking the signal slots process “connect”.:
all you had to say is that it’s not possible.
But it is... you simply don't (or maybe won't) read our answers.