QObjectList children = parent.children();QMetaMethod *metaMethod;foreach (QObject *child, children) { for (int i = child.staticMetaObject.methodOffset(); i < child.staticMetaObject->methodCount(); ++i) { metaMethod = child.staticMetaObject.metaObject->method(i); if (metaMethod.methodType() == QMetaMethod::Signal) { connect(child, QString("%1%2").arg(QSIGNAL_CODE).arg(metaMethod.signature()).toLatin1().data() , this, SLOT(YOUR_SLOT)); } }}
C++ (Qt) foreach (QObject *child, ui) { qDebug()<<child->metaObject()->className(); for (int i= child->metaObject()->methodOffset();i<child->metaObject()->methodCount();i++){ QMetaMethod metaMethod = child->metaObject()->method(i); if (metaMethod.methodType()==QMetaMethod::Signal) { c = metaMethod.signature(); qDebug()<<c; } } }
QFormInternal::TranslationWatcher QHBoxLayout QPushButton QLabel linkActivated(QString) linkHovered(QString)
QObject destroyed(QObject*) destroyed() QObject destroyed(QObject*) destroyed() QObject destroyed(QObject*) destroyed() QObject destroyed(QObject*) destroyed()
C++ (Qt)void windowloader::loadUI(QString uifile){ QUiLoader loader; QFile file(uifile); file.open(QFile::ReadOnly); QWidget *myWidget = loader.load(&file); file.close(); myWidget->show(); myWidget->children(); QObjectList ui = myWidget->children(); foreach (QObject *child, ui) {#ifdef QT_DEBUG qDebug()<<child->metaObject()->className();#endif QList<QMetaMethod>* mthl = mapMethods(child->metaObject()); for (int i=0;i<mthl->count();i++){#ifdef QT_DEBUG qDebug()<<mthl->value(i).signature();#endif qDebug()<< this->connect(child, QString("%1%2").arg(QSIGNAL_CODE).arg(mthl->value(i).signature()).toLatin1().data() , SLOT(attachslot())); } }} QList<QMetaMethod>* windowloader::mapMethods(const QMetaObject* mo, QList<QMetaMethod>* mthl){ if (mthl==0){ mthl = new QList<QMetaMethod>(); } QRegExp rx("*()"); rx.setPatternSyntax(QRegExp::Wildcard); for (int i= mo->methodOffset();i<mo->methodCount();i++){ QMetaMethod metaMethod = mo->method(i); if ((metaMethod.methodType()==QMetaMethod::Signal) && rx.exactMatch(metaMethod.signature())) { mthl->append(metaMethod); } } if (mo->superClass()){ mapMethods(mo->superClass(),mthl); } return mthl; } void windowloader::attachslot(){ qDebug()<<"work";} }
C++ (Qt)Calculator.prototype.clearAll = function()
C++ (Qt)function clearAll ()