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