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. Qt 4.8, anyway to see lists / maps of MetaObject ?

Qt 4.8, anyway to see lists / maps of MetaObject ?

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 3 Posters 725 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.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by SPlatten
    #1

    I have two connections in a configuration file:

    "dial1","dialMoved(int)","lbl1","intToString(int)"
    "lbl1","asString(const QString&)","lbl1","setText(const QString&)"
    

    The first connection works, the second doesn't, it fails on:

    const int cintSignal(cpobjSignalMeta->indexOfSignal(cpszSignal));
    const int cintSlot(cpobjSlotMeta->indexOfSlot(cpszSlot));
    if ( cintSignal < 0 || cintSlot < 0 ) {
        continue;
    }
    

    In the debugger both cintSignal and cintSlot are -1. setText is the built in slot for QLabel, asString is my signal which is emitted from the slot intToString when a dial is moved.

    I have my own derived class from QLabel which is why I have added my own signals and slots to.

    I would like to see the internals of what indexOfSignal and indexOfSlot is looking at so I can see why it is failing.

    Kind Regards,
    Sy

    jsulmJ 1 Reply Last reply
    0
    • SPlattenS SPlatten

      @KroMignon , setText is the signal on the QLabel, is it because this isn't a slot and doesn't appear in the slot methods, but it is in the signal methods.

      With normal connections I know you can connect signals to signals...

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

      @SPlatten said in Qt 4.8, anyway to see lists / maps of MetaObject ?:

      setText is the signal on the QLabel, is it because this isn't a slot and doesn't appear in the slot methods, but it is in the signal methods.
      With normal connections I know you can connect signals to signals...

      You can do the same here:

      const int cintSignal(cpobjSignalMeta->indexOfSignal(QMetaObject::normalizedSignature(cpszSignal)));
      const int cintSlot(cpobjSlotMeta->indexOfSlot(QMetaObject::normalizedSignature(cpszSlot)));
      const int cintSignal2(cpobjSlotMeta->indexOfSignal(QMetaObject::normalizedSignature(cpszSlot)));
      if ( cintSignal < 0 || (cintSlot < 0  && cintSignal2 <0)) {
          continue;
      }
      connect(src, cpobjSignalMeta->method(cintSignal), dest, cpobjSlotMeta->method(qMax(cintSlot, cintSignal2));
      

      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
      0
      • SPlattenS SPlatten

        I have two connections in a configuration file:

        "dial1","dialMoved(int)","lbl1","intToString(int)"
        "lbl1","asString(const QString&)","lbl1","setText(const QString&)"
        

        The first connection works, the second doesn't, it fails on:

        const int cintSignal(cpobjSignalMeta->indexOfSignal(cpszSignal));
        const int cintSlot(cpobjSlotMeta->indexOfSlot(cpszSlot));
        if ( cintSignal < 0 || cintSlot < 0 ) {
            continue;
        }
        

        In the debugger both cintSignal and cintSlot are -1. setText is the built in slot for QLabel, asString is my signal which is emitted from the slot intToString when a dial is moved.

        I have my own derived class from QLabel which is why I have added my own signals and slots to.

        I would like to see the internals of what indexOfSignal and indexOfSlot is looking at so I can see why it is failing.

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @SPlatten said in Qt 4.8, anyway to see lists / maps of MetaObject ?:

        I would like to see the internals of what indexOfSignal and indexOfSlot is looking at

        https://code.woboq.org/qt5/qtbase/src/corelib/kernel/qmetaobject.cpp.html#_ZNK11QMetaObject13indexOfSignalEPKc
        https://code.woboq.org/qt5/qtbase/src/corelib/kernel/qmetaobject.cpp.html#_ZNK11QMetaObject11indexOfSlotEPKc

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

        SPlattenS 1 Reply Last reply
        0
        • jsulmJ jsulm

          @SPlatten said in Qt 4.8, anyway to see lists / maps of MetaObject ?:

          I would like to see the internals of what indexOfSignal and indexOfSlot is looking at

          https://code.woboq.org/qt5/qtbase/src/corelib/kernel/qmetaobject.cpp.html#_ZNK11QMetaObject13indexOfSignalEPKc
          https://code.woboq.org/qt5/qtbase/src/corelib/kernel/qmetaobject.cpp.html#_ZNK11QMetaObject11indexOfSlotEPKc

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

          @jsulm , thank you, I just did this:

          for( int i=0; i<cpobjSignalMeta->methodCount(); i++ ) {
              qDebug() << cpobjSignalMeta->method(i).signature();
          }
          

          That dumps everything I need, its interesting because having found the signatures for the signals and slots that don't work I can see why, but I don't know why the signatures do not match the prototypes, for example the prototype for the signal asString:

          void asString(const QString&)
          

          The signature is just:

          asString(QString)
          

          Kind Regards,
          Sy

          KroMignonK jsulmJ 2 Replies Last reply
          0
          • SPlattenS SPlatten

            @jsulm , thank you, I just did this:

            for( int i=0; i<cpobjSignalMeta->methodCount(); i++ ) {
                qDebug() << cpobjSignalMeta->method(i).signature();
            }
            

            That dumps everything I need, its interesting because having found the signatures for the signals and slots that don't work I can see why, but I don't know why the signatures do not match the prototypes, for example the prototype for the signal asString:

            void asString(const QString&)
            

            The signature is just:

            asString(QString)
            
            KroMignonK Offline
            KroMignonK Offline
            KroMignon
            wrote on last edited by
            #4

            @SPlatten said in Qt 4.8, anyway to see lists / maps of MetaObject ?:

            The signature is just:
            asString(QString)

            I would suggest you to use QMetaObject::normalizedSignature():

            const int cintSignal(cpobjSignalMeta->indexOfSignal(QMetaObject::normalizedSignature(cpszSignal)));
            const int cintSlot(cpobjSlotMeta->indexOfSlot(QMetaObject::normalizedSignature(cpszSlot)));
            if ( cintSignal < 0 || cintSlot < 0 ) {
                continue;
            }
            

            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
            1
            • KroMignonK KroMignon

              @SPlatten said in Qt 4.8, anyway to see lists / maps of MetaObject ?:

              The signature is just:
              asString(QString)

              I would suggest you to use QMetaObject::normalizedSignature():

              const int cintSignal(cpobjSignalMeta->indexOfSignal(QMetaObject::normalizedSignature(cpszSignal)));
              const int cintSlot(cpobjSlotMeta->indexOfSlot(QMetaObject::normalizedSignature(cpszSlot)));
              if ( cintSignal < 0 || cintSlot < 0 ) {
                  continue;
              }
              
              SPlattenS Offline
              SPlattenS Offline
              SPlatten
              wrote on last edited by
              #5

              @KroMignon , I'm implemented your suggestion. The second connection still fails, in the dump, I can see asString appears in the slots section as does intToString.

              Kind Regards,
              Sy

              KroMignonK 1 Reply Last reply
              0
              • SPlattenS SPlatten

                @KroMignon , I'm implemented your suggestion. The second connection still fails, in the dump, I can see asString appears in the slots section as does intToString.

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

                @SPlatten said in Qt 4.8, anyway to see lists / maps of MetaObject ?:

                I'm implemented your suggestion. The second connection still fails, in the dump, I can see asString appears in the slots section as does intToString.

                Perhaps it do not work because there is a typo... setText(const QStirng&) ==> setText(const QString&)

                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 2 Replies Last reply
                0
                • KroMignonK KroMignon

                  @SPlatten said in Qt 4.8, anyway to see lists / maps of MetaObject ?:

                  I'm implemented your suggestion. The second connection still fails, in the dump, I can see asString appears in the slots section as does intToString.

                  Perhaps it do not work because there is a typo... setText(const QStirng&) ==> setText(const QString&)

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

                  @KroMignon , I wish it was true, but that's just because I have two systems in front of me, the development system which is not connected to the system I used to post on the internet, I have to manually type in the information and that was a typo in my post only.

                  Kind Regards,
                  Sy

                  1 Reply Last reply
                  0
                  • KroMignonK KroMignon

                    @SPlatten said in Qt 4.8, anyway to see lists / maps of MetaObject ?:

                    I'm implemented your suggestion. The second connection still fails, in the dump, I can see asString appears in the slots section as does intToString.

                    Perhaps it do not work because there is a typo... setText(const QStirng&) ==> setText(const QString&)

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

                    @KroMignon , setText is the signal on the QLabel, is it because this isn't a slot and doesn't appear in the slot methods, but it is in the signal methods.

                    With normal connections I know you can connect signals to signals...

                    Kind Regards,
                    Sy

                    KroMignonK 1 Reply Last reply
                    0
                    • SPlattenS SPlatten

                      @KroMignon , setText is the signal on the QLabel, is it because this isn't a slot and doesn't appear in the slot methods, but it is in the signal methods.

                      With normal connections I know you can connect signals to signals...

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

                      @SPlatten said in Qt 4.8, anyway to see lists / maps of MetaObject ?:

                      setText is the signal on the QLabel, is it because this isn't a slot and doesn't appear in the slot methods, but it is in the signal methods.
                      With normal connections I know you can connect signals to signals...

                      You can do the same here:

                      const int cintSignal(cpobjSignalMeta->indexOfSignal(QMetaObject::normalizedSignature(cpszSignal)));
                      const int cintSlot(cpobjSlotMeta->indexOfSlot(QMetaObject::normalizedSignature(cpszSlot)));
                      const int cintSignal2(cpobjSlotMeta->indexOfSignal(QMetaObject::normalizedSignature(cpszSlot)));
                      if ( cintSignal < 0 || (cintSlot < 0  && cintSignal2 <0)) {
                          continue;
                      }
                      connect(src, cpobjSignalMeta->method(cintSignal), dest, cpobjSlotMeta->method(qMax(cintSlot, cintSignal2));
                      

                      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
                      0
                      • SPlattenS SPlatten

                        @jsulm , thank you, I just did this:

                        for( int i=0; i<cpobjSignalMeta->methodCount(); i++ ) {
                            qDebug() << cpobjSignalMeta->method(i).signature();
                        }
                        

                        That dumps everything I need, its interesting because having found the signatures for the signals and slots that don't work I can see why, but I don't know why the signatures do not match the prototypes, for example the prototype for the signal asString:

                        void asString(const QString&)
                        

                        The signature is just:

                        asString(QString)
                        
                        jsulmJ Offline
                        jsulmJ Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on last edited by
                        #10

                        @SPlatten said in Qt 4.8, anyway to see lists / maps of MetaObject ?:

                        void asString(const QString&)

                        The signature is just:
                        asString(QString)

                        Because reference (&) is ignored.
                        See https://doc.qt.io/qt-5/qmetaobject.html#normalizedSignature

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

                        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