[solved] terminate application



  • if i click on onClicked: Qt.quit()
    i receive the error "Signal QDeclarativeEngine::quit() emitted, but no receivers connected to handle it."

    ideas for fixing?



  • You have to connect the QDeclarativeEngine::quit() signal to the QApplication::quit() slot.
    @
    connect(view->engine(), SIGNAL(quit()), QCoreApplication::instance(), SLOT(quit()));
    @



  • @
    QDeclarativeView *primaSchermata = new QDeclarativeView(this);
    primaSchermata->setSource(QUrl::fromLocalFile("qml/OpenOrario/main.qml"));
    primaSchermata->show();
    QObject::connect(primaSchermata->engine(), SIGNAL(quit()), QCoreApplication::instance(), SLOT(quit()));
    @

    this one does not start...



  • What does "does not start" mean?



  • Signal QDeclarativeEngine::quit() emitted, but no receivers connected to handle it.



  • The code - as you have posted - does work and the application should be closed.

    Are there any further debug outputs? Is the connect() successful?



  • no, it is not.
    @
    QObject::connect(primaSchermata->engine(), SIGNAL(quit()), QCoreApplication::instance(), SLOT(quit()));
    @
    returns
    @
    ..\OpenOrario\prima.cpp:28: error: no matching function for call to 'prima::connect(QDeclarativeEngine*, const char*, QCoreApplication*, const char*)'
    c:\QtSDK\Desktop\Qt\4.7.3\mingw\include/QtCore/qobject.h:198: note: candidates are: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)
    c:\QtSDK\Desktop\Qt\4.7.3\mingw\include/QtCore/qobject.h:313: note: bool QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const
    @

    if i delete the snippet and click on the button to close the app:
    @
    Rectangle { ... MouseArea { anchors.fill: parent; onClicked: Qt.quit() } }
    @
    there is this error:
    @
    Signal QDeclarativeEngine::quit() emitted, but no receivers connected to handle it.
    @



  • solved with
    @
    QObject::connect(obj, SIGNAL(signal_chiudiClicked()), this, SLOT(close()));
    @

    and the relative signal from QML. the class inherits from "qwidget"



  • [quote author="spode" date="1317308378"]no, it is not.[/quote]

    I could not reproduce your problem. The snippet works whatsoever I try. In addition, the signature the compiler complains about matches one of the suggested signatures - which is rather strange.

    However the problem has been solved for you.

    To all the others: please someone enlighten me why this snippet might not work and how it can be forced to produce the error stated above.



  • Hello,

    I bumped into the same problem minutes ago. You just have to remember to include both of the headers - for QDeclarativeEngine and QCoreApplication.

    Enjoy ;)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.