I am new to using the Qt framework. I am not sure where I am going wrong. I tried to look at many related materials, but still could not understand.
I get "QObject :: connect: There is no such signal error ..." while I declared the signal in a qml file.
Here is the code:
int main(int argc, char *argv[]) { QApplication app(argc, argv); //QDeclarativeView view; QQmlApplicationEngine engine; testclass dsc; QQmlComponent component(&engine, QUrl(QStringLiteral("qrc:///test.qml"))); while(component.isLoading()); if (component.isError()) { qWarning() << component.errors(); } QObject *object = component.create(); QQuickItem *item = qobject_cast<QQuickItem*>(object); QObject::connect(item,SIGNAL(dsa(QVariant)),&dsc,SLOT(testslot(QVariant))); QObject::connect(&dsc,SIGNAL(dummysignal(QVariant)),&dsc,SLOT(testslot(QVariant))); dsc.dummysignal(&dsc); qDebug("Entered :"); engine.load(QUrl(QStringLiteral("qrc:///main.qml"))); return app.exec(); }
qml file : test.qml
Item { width: 800 height: 500 signal dsa(var obj) SystemPalette { id: palette } }
Testing class : testclass.cpp
#include <QObject> class testclass: public QObject { Q_OBJECT public: explicit testclass(QObject *parent = 0); signals: void dummysignal(QVariant); public slots: void testslot(QVariant); };
I get this error:
QObject::connect: No such signal test_QMLTYPE_0::dsa(QVariant) in ..
source share