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. Signal and Slot connected by slot not called?
Forum Updated to NodeBB v4.3 + New Features

Signal and Slot connected by slot not called?

Scheduled Pinned Locked Moved Unsolved General and Desktop
23 Posts 7 Posters 5.4k Views 4 Watching
  • 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.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by
    #14

    @KroMignon said in Signal and Slot connected by slot not called?:

    emit is a semantical sugar, it has no signification, it is only for the reader to identify usage of a signal
    emit pobjModule->sendJSON(objJSON); is absolutely the same as pobjModule->sendJSON(objJSON);
    You are simply call a member, nothing more, nothing less.

    Allow me to interpret this reoccurring "sugary " statement

    emit pobjModule->sendJSON(objJSON);

    using "emit" is therefore equivalent to

    int a = 10; /// set variable a to 10

    where

    /// set variable a to 10 is a superficial sugar telling nothing about what "a" is /does

    IMHO
    repeating the "emit does nothing , it is a sugar " directly discourages to write readable code , unless the coder objective is to write obfuscated stuff for false "job security".
    Cheers
    '

    KroMignonK 1 Reply Last reply
    0
    • A Anonymous_Banned275

      @KroMignon said in Signal and Slot connected by slot not called?:

      emit is a semantical sugar, it has no signification, it is only for the reader to identify usage of a signal
      emit pobjModule->sendJSON(objJSON); is absolutely the same as pobjModule->sendJSON(objJSON);
      You are simply call a member, nothing more, nothing less.

      Allow me to interpret this reoccurring "sugary " statement

      emit pobjModule->sendJSON(objJSON);

      using "emit" is therefore equivalent to

      int a = 10; /// set variable a to 10

      where

      /// set variable a to 10 is a superficial sugar telling nothing about what "a" is /does

      IMHO
      repeating the "emit does nothing , it is a sugar " directly discourages to write readable code , unless the coder objective is to write obfuscated stuff for false "job security".
      Cheers
      '

      KroMignonK Offline
      KroMignonK Offline
      KroMignon
      wrote on last edited by
      #15

      @AnneRanch said in Signal and Slot connected by slot not called?:

      repeating the "emit does nothing , it is a sugar " directly discourages to write readable code , unless the coder objective is to write obfuscated stuff for false "job security".
      Cheers
      '

      You are misunderstanding my comments.
      All I want to say with "semantical sugar", is that there is nothing which is magically done here.
      If emitting signal is working somewhere, it will work everywhere.

      And if the slot is not called by one specific call only, it simply means that the thread event loop is not working/locked.

      I am not an English native speaker, so I try to explain the best I can.

      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

      SPlattenS 1 Reply Last reply
      0
      • KroMignonK KroMignon

        @AnneRanch said in Signal and Slot connected by slot not called?:

        repeating the "emit does nothing , it is a sugar " directly discourages to write readable code , unless the coder objective is to write obfuscated stuff for false "job security".
        Cheers
        '

        You are misunderstanding my comments.
        All I want to say with "semantical sugar", is that there is nothing which is magically done here.
        If emitting signal is working somewhere, it will work everywhere.

        And if the slot is not called by one specific call only, it simply means that the thread event loop is not working/locked.

        I am not an English native speaker, so I try to explain the best I can.

        SPlattenS Offline
        SPlattenS Offline
        SPlatten
        wrote on last edited by
        #16

        @KroMignon , thank you, np.

        Kind Regards,
        Sy

        rrlopezR 1 Reply Last reply
        0
        • JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #17

          @SPlatten :

          • Write a qDebug() message just after the QObject::connect(this, &clsModule::sendJSON, this, &clsModule::onSendJSON);.
          • Write a qDebug() message just after the emit pobjModule->sendJSON(objJSON);
          • Write a qDebug() message at the start just after the clsModule::onSendJSON()

          Questions:

          1. When you run your program, which debug messages above get printed to output?
          2. Which thread does your clsModule object live in?
          3. Which thread do you call clsJSON::sendAck() from?
          4. Why does clsModule inherit QProcess?

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          1 Reply Last reply
          1
          • A Offline
            A Offline
            Anonymous_Banned275
            wrote on last edited by
            #18

            @KroMignon said in Signal and Slot connected by slot not called?:

            I am not an English native speaker, so I try to explain the best I can.

            Neither am I .
            Telling me I do not understand what you wrote is not the subject of discussion.
            And it works BOTH ways.

            Let me try it another way - "emit" is not a keyword.
            It is a macro and has a purpose / function in the code.
            Its placement is important.

            BUT if majority of forum participators will keep downgrading "emit" to "sugar" it does not mean such attitude is the best.

            Just to make sure - I object ONLY to your treatment of "emit" , I have no comment to the rest of you post.

            J.HilkJ Pl45m4P 2 Replies Last reply
            0
            • A Anonymous_Banned275

              @KroMignon said in Signal and Slot connected by slot not called?:

              I am not an English native speaker, so I try to explain the best I can.

              Neither am I .
              Telling me I do not understand what you wrote is not the subject of discussion.
              And it works BOTH ways.

              Let me try it another way - "emit" is not a keyword.
              It is a macro and has a purpose / function in the code.
              Its placement is important.

              BUT if majority of forum participators will keep downgrading "emit" to "sugar" it does not mean such attitude is the best.

              Just to make sure - I object ONLY to your treatment of "emit" , I have no comment to the rest of you post.

              J.HilkJ Online
              J.HilkJ Online
              J.Hilk
              Moderators
              wrote on last edited by J.Hilk
              #19

              @AnneRanch said in Signal and Slot connected by slot not called?:

              Let me try it another way - "emit" is not a keyword.

              true

              It is a macro

              true(ish)

              and has a purpose / function in the code.

              false

              Its placement is important.

              false

              here's the definition of emit

              #ifndef QT_NO_EMIT
              # define emit
              #endif
              

              its quite literally expands to nothing


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              1 Reply Last reply
              3
              • A Anonymous_Banned275

                @KroMignon said in Signal and Slot connected by slot not called?:

                I am not an English native speaker, so I try to explain the best I can.

                Neither am I .
                Telling me I do not understand what you wrote is not the subject of discussion.
                And it works BOTH ways.

                Let me try it another way - "emit" is not a keyword.
                It is a macro and has a purpose / function in the code.
                Its placement is important.

                BUT if majority of forum participators will keep downgrading "emit" to "sugar" it does not mean such attitude is the best.

                Just to make sure - I object ONLY to your treatment of "emit" , I have no comment to the rest of you post.

                Pl45m4P Offline
                Pl45m4P Offline
                Pl45m4
                wrote on last edited by
                #20

                @AnneRanch said in Signal and Slot connected by slot not called?:

                It is a macro and has a purpose / function in the code.

                It's just for debug purposes and to increase the readability. You can say from looking at the emit, that you "call" (or emit) a signal next. Without, it would be hard(er) to say, where exactly you emit your signals. You would need to follow the trace of every signal.


                If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                ~E. W. Dijkstra

                1 Reply Last reply
                1
                • SPlattenS SPlatten

                  @KroMignon , thank you, np.

                  rrlopezR Offline
                  rrlopezR Offline
                  rrlopez
                  wrote on last edited by
                  #21

                  @JKSH said in Signal and Slot connected by slot not called?:

                  @SPlatten :

                  • Write a qDebug() message just after the QObject::connect(this, &clsModule::sendJSON, this, &clsModule::onSendJSON);.
                  • Write a qDebug() message just after the emit pobjModule->sendJSON(objJSON);
                  • Write a qDebug() message at the start just after the clsModule::onSendJSON()

                  Questions:

                  1. When you run your program, which debug messages above get printed to output?
                  2. Which thread does your clsModule object live in?
                  3. Which thread do you call clsJSON::sendAck() from?
                  4. Why does clsModule inherit QProcess?

                  I would also suggest adding to the debug log the result of the connection to verify that the connection is actually done correctly. Also, I have a question. On your output log do you see some log related to the module clsModule not being registered using qRegisterMetaType() or anything like that when you try to perform your connection? It may be that we need to register this module as a meta type in order to use it on the connections.

                  Lic-Ing. Rodrigo Lopez Gonzalez
                  Embedded Software Engineer
                  RidgeRun Engineering Ltd.
                  www.ridgerun.com
                  Email: rodrigo.lopez@ridgerun.com

                  SPlattenS 1 Reply Last reply
                  0
                  • rrlopezR rrlopez

                    @JKSH said in Signal and Slot connected by slot not called?:

                    @SPlatten :

                    • Write a qDebug() message just after the QObject::connect(this, &clsModule::sendJSON, this, &clsModule::onSendJSON);.
                    • Write a qDebug() message just after the emit pobjModule->sendJSON(objJSON);
                    • Write a qDebug() message at the start just after the clsModule::onSendJSON()

                    Questions:

                    1. When you run your program, which debug messages above get printed to output?
                    2. Which thread does your clsModule object live in?
                    3. Which thread do you call clsJSON::sendAck() from?
                    4. Why does clsModule inherit QProcess?

                    I would also suggest adding to the debug log the result of the connection to verify that the connection is actually done correctly. Also, I have a question. On your output log do you see some log related to the module clsModule not being registered using qRegisterMetaType() or anything like that when you try to perform your connection? It may be that we need to register this module as a meta type in order to use it on the connections.

                    SPlattenS Offline
                    SPlattenS Offline
                    SPlatten
                    wrote on last edited by
                    #22

                    @rrlopez , what makes you say I need to register clsModule as a type? I don't pass that as a signal parameter I only pass QJsonObject.

                    Kind Regards,
                    Sy

                    1 Reply Last reply
                    0
                    • rrlopezR Offline
                      rrlopezR Offline
                      rrlopez
                      wrote on last edited by
                      #23

                      I was just asking if you had a message on your output log. If you don't get that message then you don't need to register clsModule as a type. What interest me the most is the result of the connection. If you create a QMetaObject::Connection object and assign it to the connection you're trying to do, is it valid? you can check that by doing something like this:

                      QMetaObject::Connection testConnection = QObject::connect(this, &clsModule::sendJSON, this, &clsModule::onSendJSON);
                      if (!testConnection)
                      {
                            // handle testConnection invalid case (or print error message)
                      }
                      

                      Lic-Ing. Rodrigo Lopez Gonzalez
                      Embedded Software Engineer
                      RidgeRun Engineering Ltd.
                      www.ridgerun.com
                      Email: rodrigo.lopez@ridgerun.com

                      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