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.6k 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.
  • KroMignonK KroMignon

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

    But no mov_clsJSON.o

    Of course there is not moc file for this class, it has no Q_OBJECT, nor it is a QObject sub-class , nor it have signals or slots!

    In you code extract, you are talking about clsModule not clsJSON, now I am again totally lost... what is the purpose of your question?

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

    @KroMignon , here is the content of the file moc_clsModule.cpp:

    /****************************************************************************
    ** Meta object code from reading C++ file 'clsModule.h'
    **
    ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.15.2)
    **
    ** WARNING! All changes made in this file will be lost!
    *****************************************************************************/
    
    #include <memory>
    #include "../clsModule.h"
    #include <QtCore/qbytearray.h>
    #include <QtCore/qmetatype.h>
    #if !defined(Q_MOC_OUTPUT_REVISION)
    #error "The header file 'clsModule.h' doesn't include <QObject>."
    #elif Q_MOC_OUTPUT_REVISION != 67
    #error "This file was generated using the moc from 5.15.2. It"
    #error "cannot be used with the include files from this version of Qt."
    #error "(The moc has changed too much.)"
    #endif
    
    QT_BEGIN_MOC_NAMESPACE
    QT_WARNING_PUSH
    QT_WARNING_DISABLE_DEPRECATED
    struct qt_meta_stringdata_clsModule_t {
        QByteArrayData data[12];
        char stringdata0[106];
    };
    #define QT_MOC_LITERAL(idx, ofs, len) \
        Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
        qptrdiff(offsetof(qt_meta_stringdata_clsModule_t, stringdata0) + ofs \
            - idx * sizeof(QByteArrayData)) \
        )
    static const qt_meta_stringdata_clsModule_t qt_meta_stringdata_clsModule = {
        {
    QT_MOC_LITERAL(0, 0, 9), // "clsModule"
    QT_MOC_LITERAL(1, 10, 3), // "PID"
    QT_MOC_LITERAL(2, 14, 0), // ""
    QT_MOC_LITERAL(3, 15, 11), // "crstrProces"
    QT_MOC_LITERAL(4, 27, 8), // "int64PID"
    QT_MOC_LITERAL(5, 36, 7), // "sendAck"
    QT_MOC_LITERAL(6, 44, 9), // "crobjJSON"
    QT_MOC_LITERAL(7, 54, 8), // "sendJSON"
    QT_MOC_LITERAL(8, 63, 12), // "QJsonObject&"
    QT_MOC_LITERAL(9, 76, 8), // "robjJSON"
    QT_MOC_LITERAL(10, 85, 9), // "onSendAck"
    QT_MOC_LITERAL(11, 95, 10) // "onSendJSON"
    
        },
        "clsModule\0PID\0\0crstrProces\0int64PID\0"
        "sendAck\0crobjJSON\0sendJSON\0QJsonObject&\0"
        "robjJSON\0onSendAck\0onSendJSON"
    };
    #undef QT_MOC_LITERAL
    
    static const uint qt_meta_data_clsModule[] = {
    
     // content:
           8,       // revision
           0,       // classname
           0,    0, // classinfo
           5,   14, // methods
           0,    0, // properties
           0,    0, // enums/sets
           0,    0, // constructors
           0,       // flags
           3,       // signalCount
    
     // signals: name, argc, parameters, tag, flags
           1,    2,   39,    2, 0x06 /* Public */,
           5,    1,   44,    2, 0x06 /* Public */,
           7,    1,   47,    2, 0x06 /* Public */,
    
     // slots: name, argc, parameters, tag, flags
          10,    1,   50,    2, 0x0a /* Public */,
          11,    1,   53,    2, 0x0a /* Public */,
    
     // signals: parameters
        QMetaType::Void, QMetaType::QString, QMetaType::LongLong,    3,    4,
        QMetaType::Void, QMetaType::QJsonObject,    6,
        QMetaType::Void, 0x80000000 | 8,    9,
    
     // slots: parameters
        QMetaType::Void, QMetaType::QJsonObject,    6,
        QMetaType::Void, 0x80000000 | 8,    9,
    
           0        // eod
    };
    
    void clsModule::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
    {
        if (_c == QMetaObject::InvokeMetaMethod) {
            auto *_t = static_cast<clsModule *>(_o);
            Q_UNUSED(_t)
            switch (_id) {
            case 0: _t->PID((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const qint64(*)>(_a[2]))); break;
            case 1: _t->sendAck((*reinterpret_cast< const QJsonObject(*)>(_a[1]))); break;
            case 2: _t->sendJSON((*reinterpret_cast< QJsonObject(*)>(_a[1]))); break;
            case 3: _t->onSendAck((*reinterpret_cast< const QJsonObject(*)>(_a[1]))); break;
            case 4: _t->onSendJSON((*reinterpret_cast< QJsonObject(*)>(_a[1]))); break;
            default: ;
            }
        } else if (_c == QMetaObject::IndexOfMethod) {
            int *result = reinterpret_cast<int *>(_a[0]);
            {
                using _t = void (clsModule::*)(const QString & , const qint64 & );
                if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&clsModule::PID)) {
                    *result = 0;
                    return;
                }
            }
            {
                using _t = void (clsModule::*)(const QJsonObject & );
                if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&clsModule::sendAck)) {
                    *result = 1;
                    return;
                }
            }
            {
                using _t = void (clsModule::*)(QJsonObject & );
                if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&clsModule::sendJSON)) {
                    *result = 2;
                    return;
                }
            }
        }
    }
    
    QT_INIT_METAOBJECT const QMetaObject clsModule::staticMetaObject = { {
        QMetaObject::SuperData::link<QProcess::staticMetaObject>(),
        qt_meta_stringdata_clsModule.data,
        qt_meta_data_clsModule,
        qt_static_metacall,
        nullptr,
        nullptr
    } };
    
    
    const QMetaObject *clsModule::metaObject() const
    {
        return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
    }
    
    void *clsModule::qt_metacast(const char *_clname)
    {
        if (!_clname) return nullptr;
        if (!strcmp(_clname, qt_meta_stringdata_clsModule.stringdata0))
            return static_cast<void*>(this);
        return QProcess::qt_metacast(_clname);
    }
    
    int clsModule::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
    {
        _id = QProcess::qt_metacall(_c, _id, _a);
        if (_id < 0)
            return _id;
        if (_c == QMetaObject::InvokeMetaMethod) {
            if (_id < 5)
                qt_static_metacall(this, _c, _id, _a);
            _id -= 5;
        } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
            if (_id < 5)
                *reinterpret_cast<int*>(_a[0]) = -1;
            _id -= 5;
        }
        return _id;
    }
    
    // SIGNAL 0
    void clsModule::PID(const QString & _t1, const qint64 & _t2)
    {
        void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t1))), const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t2))) };
        QMetaObject::activate(this, &staticMetaObject, 0, _a);
    }
    
    // SIGNAL 1
    void clsModule::sendAck(const QJsonObject & _t1)
    {
        void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t1))) };
        QMetaObject::activate(this, &staticMetaObject, 1, _a);
    }
    
    // SIGNAL 2
    void clsModule::sendJSON(QJsonObject & _t1)
    {
        void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t1))) };
        QMetaObject::activate(this, &staticMetaObject, 2, _a);
    }
    QT_WARNING_POP
    QT_END_MOC_NAMESPACE
    

    The reason I posted clsJSON.h is that the emit that isn't working is called from a static method of this class:

    void clsJSON::sendAck(const QJsonObject& crobjJSON) {
        QJsonObject::const_iterator citrCmdType = crobjJSON.find(clsJSON::mscszMsgType)
                                   ,citrSourceFound = crobjJSON.find(clsJSON::mscszSource);
        if ( citrCmdType == crobjJSON.end() || citrSourceFound == crobjJSON.end() ) {
            return;
        }
        const QString cstrMsgType = citrCmdType->toString()
                     ,cstrSource = citrSourceFound->toString();
        clsModule* pobjModule = clsModule::pGetModule(cstrSource);
    
        if ( pobjModule == nullptr ) {
            return;
        }
        //Build up acknowedge response
        QJsonObject objJSON;
        //Add the modified acknowledge message type
        QString strAckMsgType(clsJSON::mscszAck + cstrMsgType);
        objJSON.insert(clsJSON::mscszMsgType, strAckMsgType);
        //This needs to be XMLMPAM as its the only app that can acknowledge (At this time)!
        objJSON.insert(clsJSON::mscszSource, clsDebugService::cstrPrefix());
        emit pobjModule->sendJSON(objJSON);
    }
    

    Kind Regards,
    Sy

    KroMignonK 1 Reply Last reply
    0
    • SPlattenS SPlatten

      @KroMignon , here is the content of the file moc_clsModule.cpp:

      /****************************************************************************
      ** Meta object code from reading C++ file 'clsModule.h'
      **
      ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.15.2)
      **
      ** WARNING! All changes made in this file will be lost!
      *****************************************************************************/
      
      #include <memory>
      #include "../clsModule.h"
      #include <QtCore/qbytearray.h>
      #include <QtCore/qmetatype.h>
      #if !defined(Q_MOC_OUTPUT_REVISION)
      #error "The header file 'clsModule.h' doesn't include <QObject>."
      #elif Q_MOC_OUTPUT_REVISION != 67
      #error "This file was generated using the moc from 5.15.2. It"
      #error "cannot be used with the include files from this version of Qt."
      #error "(The moc has changed too much.)"
      #endif
      
      QT_BEGIN_MOC_NAMESPACE
      QT_WARNING_PUSH
      QT_WARNING_DISABLE_DEPRECATED
      struct qt_meta_stringdata_clsModule_t {
          QByteArrayData data[12];
          char stringdata0[106];
      };
      #define QT_MOC_LITERAL(idx, ofs, len) \
          Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
          qptrdiff(offsetof(qt_meta_stringdata_clsModule_t, stringdata0) + ofs \
              - idx * sizeof(QByteArrayData)) \
          )
      static const qt_meta_stringdata_clsModule_t qt_meta_stringdata_clsModule = {
          {
      QT_MOC_LITERAL(0, 0, 9), // "clsModule"
      QT_MOC_LITERAL(1, 10, 3), // "PID"
      QT_MOC_LITERAL(2, 14, 0), // ""
      QT_MOC_LITERAL(3, 15, 11), // "crstrProces"
      QT_MOC_LITERAL(4, 27, 8), // "int64PID"
      QT_MOC_LITERAL(5, 36, 7), // "sendAck"
      QT_MOC_LITERAL(6, 44, 9), // "crobjJSON"
      QT_MOC_LITERAL(7, 54, 8), // "sendJSON"
      QT_MOC_LITERAL(8, 63, 12), // "QJsonObject&"
      QT_MOC_LITERAL(9, 76, 8), // "robjJSON"
      QT_MOC_LITERAL(10, 85, 9), // "onSendAck"
      QT_MOC_LITERAL(11, 95, 10) // "onSendJSON"
      
          },
          "clsModule\0PID\0\0crstrProces\0int64PID\0"
          "sendAck\0crobjJSON\0sendJSON\0QJsonObject&\0"
          "robjJSON\0onSendAck\0onSendJSON"
      };
      #undef QT_MOC_LITERAL
      
      static const uint qt_meta_data_clsModule[] = {
      
       // content:
             8,       // revision
             0,       // classname
             0,    0, // classinfo
             5,   14, // methods
             0,    0, // properties
             0,    0, // enums/sets
             0,    0, // constructors
             0,       // flags
             3,       // signalCount
      
       // signals: name, argc, parameters, tag, flags
             1,    2,   39,    2, 0x06 /* Public */,
             5,    1,   44,    2, 0x06 /* Public */,
             7,    1,   47,    2, 0x06 /* Public */,
      
       // slots: name, argc, parameters, tag, flags
            10,    1,   50,    2, 0x0a /* Public */,
            11,    1,   53,    2, 0x0a /* Public */,
      
       // signals: parameters
          QMetaType::Void, QMetaType::QString, QMetaType::LongLong,    3,    4,
          QMetaType::Void, QMetaType::QJsonObject,    6,
          QMetaType::Void, 0x80000000 | 8,    9,
      
       // slots: parameters
          QMetaType::Void, QMetaType::QJsonObject,    6,
          QMetaType::Void, 0x80000000 | 8,    9,
      
             0        // eod
      };
      
      void clsModule::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
      {
          if (_c == QMetaObject::InvokeMetaMethod) {
              auto *_t = static_cast<clsModule *>(_o);
              Q_UNUSED(_t)
              switch (_id) {
              case 0: _t->PID((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const qint64(*)>(_a[2]))); break;
              case 1: _t->sendAck((*reinterpret_cast< const QJsonObject(*)>(_a[1]))); break;
              case 2: _t->sendJSON((*reinterpret_cast< QJsonObject(*)>(_a[1]))); break;
              case 3: _t->onSendAck((*reinterpret_cast< const QJsonObject(*)>(_a[1]))); break;
              case 4: _t->onSendJSON((*reinterpret_cast< QJsonObject(*)>(_a[1]))); break;
              default: ;
              }
          } else if (_c == QMetaObject::IndexOfMethod) {
              int *result = reinterpret_cast<int *>(_a[0]);
              {
                  using _t = void (clsModule::*)(const QString & , const qint64 & );
                  if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&clsModule::PID)) {
                      *result = 0;
                      return;
                  }
              }
              {
                  using _t = void (clsModule::*)(const QJsonObject & );
                  if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&clsModule::sendAck)) {
                      *result = 1;
                      return;
                  }
              }
              {
                  using _t = void (clsModule::*)(QJsonObject & );
                  if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&clsModule::sendJSON)) {
                      *result = 2;
                      return;
                  }
              }
          }
      }
      
      QT_INIT_METAOBJECT const QMetaObject clsModule::staticMetaObject = { {
          QMetaObject::SuperData::link<QProcess::staticMetaObject>(),
          qt_meta_stringdata_clsModule.data,
          qt_meta_data_clsModule,
          qt_static_metacall,
          nullptr,
          nullptr
      } };
      
      
      const QMetaObject *clsModule::metaObject() const
      {
          return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
      }
      
      void *clsModule::qt_metacast(const char *_clname)
      {
          if (!_clname) return nullptr;
          if (!strcmp(_clname, qt_meta_stringdata_clsModule.stringdata0))
              return static_cast<void*>(this);
          return QProcess::qt_metacast(_clname);
      }
      
      int clsModule::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
      {
          _id = QProcess::qt_metacall(_c, _id, _a);
          if (_id < 0)
              return _id;
          if (_c == QMetaObject::InvokeMetaMethod) {
              if (_id < 5)
                  qt_static_metacall(this, _c, _id, _a);
              _id -= 5;
          } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
              if (_id < 5)
                  *reinterpret_cast<int*>(_a[0]) = -1;
              _id -= 5;
          }
          return _id;
      }
      
      // SIGNAL 0
      void clsModule::PID(const QString & _t1, const qint64 & _t2)
      {
          void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t1))), const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t2))) };
          QMetaObject::activate(this, &staticMetaObject, 0, _a);
      }
      
      // SIGNAL 1
      void clsModule::sendAck(const QJsonObject & _t1)
      {
          void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t1))) };
          QMetaObject::activate(this, &staticMetaObject, 1, _a);
      }
      
      // SIGNAL 2
      void clsModule::sendJSON(QJsonObject & _t1)
      {
          void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t1))) };
          QMetaObject::activate(this, &staticMetaObject, 2, _a);
      }
      QT_WARNING_POP
      QT_END_MOC_NAMESPACE
      

      The reason I posted clsJSON.h is that the emit that isn't working is called from a static method of this class:

      void clsJSON::sendAck(const QJsonObject& crobjJSON) {
          QJsonObject::const_iterator citrCmdType = crobjJSON.find(clsJSON::mscszMsgType)
                                     ,citrSourceFound = crobjJSON.find(clsJSON::mscszSource);
          if ( citrCmdType == crobjJSON.end() || citrSourceFound == crobjJSON.end() ) {
              return;
          }
          const QString cstrMsgType = citrCmdType->toString()
                       ,cstrSource = citrSourceFound->toString();
          clsModule* pobjModule = clsModule::pGetModule(cstrSource);
      
          if ( pobjModule == nullptr ) {
              return;
          }
          //Build up acknowedge response
          QJsonObject objJSON;
          //Add the modified acknowledge message type
          QString strAckMsgType(clsJSON::mscszAck + cstrMsgType);
          objJSON.insert(clsJSON::mscszMsgType, strAckMsgType);
          //This needs to be XMLMPAM as its the only app that can acknowledge (At this time)!
          objJSON.insert(clsJSON::mscszSource, clsDebugService::cstrPrefix());
          emit pobjModule->sendJSON(objJSON);
      }
      
      KroMignonK Offline
      KroMignonK Offline
      KroMignon
      wrote on last edited by KroMignon
      #12

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

      The reason I posted clsJSON.h is that the emit that isn't working is called from a static method of this class:

      Again:

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

      • signals are in fact functions

      • corresponding function for a signal for a given class is automatically generated by moc during compilation

      • this generated function is always a public function in the class (in your example in clsModule)

      Typically implementation will record slot call in event loop of the thread from receiver.
      So to ensure slot will be called, the event loop of the receiver must not be locked.

      I don't know how to explain it better.

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

      1 Reply Last reply
      2
      • KroMignonK KroMignon

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

        But no mov_clsJSON.o

        Of course there is not moc file for this class, it has no Q_OBJECT, nor it is a QObject sub-class , nor it have signals or slots!

        In you code extract, you are talking about clsModule not clsJSON, now I am again totally lost... what is the purpose of your question?

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

        @SPlatten

        You dont use Signals&Slots in clsJSON directly, which is totally fine, but AFAIK you also can't emit signals in other classes (which do inherit from QObject, have macro and so on), when not having the Q_OBJECT macro. This is the case here, I guess.


        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
        0
        • 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 Offline
                    J.HilkJ Offline
                    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