Important: Please read the Qt Code of Conduct -

Qml signal doesn't take effect

  • Hi,

    I've created a Qt Quick 2.5 app and connected signals and slots to my c++ module,
    I only can send signals from c++ and activate QML slots, but I can't receive QML signals in c++

    here is my main:

    int main(int argc, char *argv[])
        QApplication app(argc, argv);
        QQmlApplicationEngine engine;
        return app.exec();

    here is my QML code which holds the signal:

    MouseArea {
        id: mainButtonMouseArea
        objectName: "mainButtonMouseArea"
        anchors.fill: parent
        signal signalClicked()
        onClicked: {

    I always get the console message from qml when I click on the MouseArea.

    here is my c++ constructor:

    AlfredApp::AlfredApp(QObject* viewRootObject, QObject* parent)
        : QObject(parent), d(new Private)
        d->viewRootObject = viewRootObject;
        d->viewMainButton = viewRootObject->findChild<QObject*>("mainButton");
        d->viewMainButtonIcon = viewRootObject->findChild<QObject*>("mainButtonIcon");
        d->viewMainButtonMouseArea = viewRootObject->findChild<QObject*>("mainButtonMouseArea");
        // Signals/Slots connection
        connect(d->viewMainButtonMouseArea, SIGNAL(signalClicked()),
            this, SLOT(mainButtonClicked()));
        connect(this, SIGNAL(signalListening()),
            d->viewMainButtonIcon, SLOT(listening()));
        connect(this, SIGNAL(signalProcessing()),
            d->viewMainButtonIcon, SLOT(processing()));

    Here is my slot that never gets called:

    void AlfredApp::mainButtonClicked()
        qDebug() << "Main Button Clicked";

    BTW, there is some qml code that has slots/function that respond normally to C++ singals

  • Moderators

    Hi @tootis and Welcome,

    Have you made sure that the exact object has been found ? I'm referring to this line:

  • @p3c0 Yes

  • Do you get any messages about slots/signals when connecting?(what I mean is "no such slot/signal")

Log in to reply