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. connect to a signal
Forum Updated to NodeBB v4.3 + New Features

connect to a signal

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 2 Posters 563 Views 1 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.
  • V Offline
    V Offline
    viniltc
    wrote on last edited by
    #1

    Hi all,

    I'm trying to connect to a signal as follows

     connect(&api, SIGNAL(tetraGripEvent()), this, SLOT(eventHandler()));
    

    But it says No such signal tetra_grip_api::tetraGripEvent(), let me explain the scenario:

    I have defined the signal in a class called tetra_grip_api as follows:

    void tetra_grip_reporter(STIM_GUI_TOPIC_T topic, uint8_t reg, uint32_t value)
    {
        emit api.tetraGripEvent(topic, reg, value);
    }
    

    where tetra_grip_reporter need to be called from a c file, so I defined it as:

    #ifdef __cplusplus
    extern "C" {
    #endif
    
    void tetra_grip_reporter(STIM_GUI_TOPIC_T topic, uint8_t reg, uint32_t value);
    
    #ifdef __cplusplus
    }
    #endif
    
    I don't know where I'm wrong. Any help would be welcome.
    
    Thanks in advance
    
    jsulmJ 2 Replies Last reply
    0
    • V viniltc

      Hi all,

      I'm trying to connect to a signal as follows

       connect(&api, SIGNAL(tetraGripEvent()), this, SLOT(eventHandler()));
      

      But it says No such signal tetra_grip_api::tetraGripEvent(), let me explain the scenario:

      I have defined the signal in a class called tetra_grip_api as follows:

      void tetra_grip_reporter(STIM_GUI_TOPIC_T topic, uint8_t reg, uint32_t value)
      {
          emit api.tetraGripEvent(topic, reg, value);
      }
      

      where tetra_grip_reporter need to be called from a c file, so I defined it as:

      #ifdef __cplusplus
      extern "C" {
      #endif
      
      void tetra_grip_reporter(STIM_GUI_TOPIC_T topic, uint8_t reg, uint32_t value);
      
      #ifdef __cplusplus
      }
      #endif
      
      I don't know where I'm wrong. Any help would be welcome.
      
      Thanks in advance
      
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @viniltc You need to have tetraGripEvent declared as signal in tetra_grip_api:

      class tetra_grip_api : public QObject
      {
          Q_OBJECT
      signals:
          void tetraGripEvent();
      }
      

      The class has to be derived from QObject and have Q_OBJECT macro. See https://doc.qt.io/qt-5/signalsandslots.html
      Does it look like this in your code?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      4
      • V viniltc

        Hi all,

        I'm trying to connect to a signal as follows

         connect(&api, SIGNAL(tetraGripEvent()), this, SLOT(eventHandler()));
        

        But it says No such signal tetra_grip_api::tetraGripEvent(), let me explain the scenario:

        I have defined the signal in a class called tetra_grip_api as follows:

        void tetra_grip_reporter(STIM_GUI_TOPIC_T topic, uint8_t reg, uint32_t value)
        {
            emit api.tetraGripEvent(topic, reg, value);
        }
        

        where tetra_grip_reporter need to be called from a c file, so I defined it as:

        #ifdef __cplusplus
        extern "C" {
        #endif
        
        void tetra_grip_reporter(STIM_GUI_TOPIC_T topic, uint8_t reg, uint32_t value);
        
        #ifdef __cplusplus
        }
        #endif
        
        I don't know where I'm wrong. Any help would be welcome.
        
        Thanks in advance
        
        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @viniltc said in connect to a signal:

        I have defined the signal in a class called tetra_grip_api as follows:

        And this is not a definition of a signal. Here you emit the signal.
        Also, you're passing 3 parameters to the signal but in the connect your signals/slots do NOT have any parameters.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        5
        • V Offline
          V Offline
          viniltc
          wrote on last edited by
          #4

          @jsulm Thanks for your reply.
          Yes, I defined the signal as follows:

          class tetra_grip_api : public QObject
          {
              Q_OBJECT
          signals:
              void tetraGripEvent(STIM_GUI_TOPIC_T topic, uint8_t reg, uint32_t value);
          
          jsulmJ 1 Reply Last reply
          0
          • V viniltc

            @jsulm Thanks for your reply.
            Yes, I defined the signal as follows:

            class tetra_grip_api : public QObject
            {
                Q_OBJECT
            signals:
                void tetraGripEvent(STIM_GUI_TOPIC_T topic, uint8_t reg, uint32_t value);
            
            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @viniltc Then your connect is wrong as you have not specified any parameters there.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            1
            • V Offline
              V Offline
              viniltc
              wrote on last edited by
              #6

              @jsulm
              Do you mean to define as follows?

              connect(&api, SIGNAL(tetraGripEvent(topic, reg, value)), this, SLOT(eventHandler()));
              
              jsulmJ 1 Reply Last reply
              0
              • V viniltc

                @jsulm
                Do you mean to define as follows?

                connect(&api, SIGNAL(tetraGripEvent(topic, reg, value)), this, SLOT(eventHandler()));
                
                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @viniltc said in connect to a signal:

                Do you mean to define as follows?

                No

                connect(&api, SIGNAL(tetraGripEvent(STIM_GUI_TOPIC_T, uint8_t, uint32_t)), this, SLOT(eventHandler(STIM_GUI_TOPIC_T, uint8_t, uint32_t)));
                

                You have to specify the types of the parameters.
                See the link I gave you.

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                4
                • V Offline
                  V Offline
                  viniltc
                  wrote on last edited by
                  #8

                  @jsulm Thanks a lot for your feedback! That's fixed

                  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