Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How do I call the C function “connect” with out invoking the signal slots process “connect”.

How do I call the C function “connect” with out invoking the signal slots process “connect”.

Scheduled Pinned Locked Moved Solved General and Desktop
c codenaming conflictqt 5.8
13 Posts 5 Posters 2.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Christian EhrlicherC Offline
    Christian EhrlicherC Offline
    Christian Ehrlicher
    Lifetime Qt Champion
    wrote on last edited by
    #4

    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().

    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
    Visit the Qt Academy at https://academy.qt.io/catalog

    D 1 Reply Last reply
    2
    • Christian EhrlicherC Christian Ehrlicher

      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().

      D Offline
      D Offline
      DaShubWubDub
      wrote on last edited by
      #5

      @Christian-Ehrlicher

      It’s C code so namespaces do not exist, it’s strictly call by function names only.

      Christian EhrlicherC JonBJ 2 Replies Last reply
      0
      • D DaShubWubDub

        @Christian-Ehrlicher

        It’s C code so namespaces do not exist, it’s strictly call by function names only.

        Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #6

        @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.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        2
        • D DaShubWubDub

          @Christian-Ehrlicher

          It’s C code so namespaces do not exist, it’s strictly call by function names only.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #7

          @DaShubWubDub
          In C code you cannot call C++ code, such as QObject::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 library connect().

          Like @Christian-Ehrlicher says.

          D 1 Reply Last reply
          1
          • JonBJ JonB

            @DaShubWubDub
            In C code you cannot call C++ code, such as QObject::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 library connect().

            Like @Christian-Ehrlicher says.

            D Offline
            D Offline
            DaShubWubDub
            wrote on last edited by
            #8

            @JonB you are exactly correct however you can create a signal slot connection by calling connect(object, signal(), class, slot());

            So somewhere by default Qt uses, use name space qobject. How would I disable that convenience?

            C JonBJ Christian EhrlicherC 3 Replies Last reply
            0
            • D DaShubWubDub

              @JonB you are exactly correct however you can create a signal slot connection by calling connect(object, signal(), class, slot());

              So somewhere by default Qt uses, use name space qobject. How would I disable that convenience?

              C Offline
              C Offline
              ChrisW67
              wrote on last edited by ChrisW67
              #9

              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 other connect() 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.

              1 Reply Last reply
              2
              • D DaShubWubDub

                @JonB you are exactly correct however you can create a signal slot connection by calling connect(object, signal(), class, slot());

                So somewhere by default Qt uses, use name space qobject. How would I disable that convenience?

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by JonB
                #10

                @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 to QObject::connect() is if you are inside a class which inherits from QObject. And if you are in that situation you have to write ::connect() to refer to C runtime library's connect(). That is what you must do. ::connect() won't work in truly C code, but then if you are inside a class derived from QObject you must be in C++ rather than C anyway.

                1 Reply Last reply
                0
                • D DaShubWubDub

                  @JonB you are exactly correct however you can create a signal slot connection by calling connect(object, signal(), class, slot());

                  So somewhere by default Qt uses, use name space qobject. How would I disable that convenience?

                  Christian EhrlicherC Offline
                  Christian EhrlicherC Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by Christian Ehrlicher
                  #11

                  @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...

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  D 1 Reply Last reply
                  1
                  • Christian EhrlicherC 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...

                    D Offline
                    D Offline
                    DaShubWubDub
                    wrote on last edited by
                    #12

                    @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 EhrlicherC 1 Reply Last reply
                    0
                    • D DaShubWubDub

                      @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 EhrlicherC Offline
                      Christian EhrlicherC Offline
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on last edited by Christian Ehrlicher
                      #13

                      @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.

                      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                      Visit the Qt Academy at https://academy.qt.io/catalog

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved