Connecting qml complex signal to qt slot



  • file.cpp
    @
    ...
    QObject::connect(obj_schermataCreaNuovaParola, SIGNAL(signal_richiestaSalvataggio(string , string , string , string , string , bool )),this, SLOT(salvaBiglietto(QString deutscheswort, QString deutscherbeispiel, QString parolaitaliana, QString esempioitaliano, QString type, bool isImportante)));
    ...
    @

    file.qml
    @
    ...
    onClicked: signal_richiestaSalvataggio(deutschesWort.text, deutscherBeispiel.text, parolaItaliana.text, esempioItaliano.text, tipo, importante);
    ...
    @

    now, as i click on a mousearea, it will be emitted that signal, that ought to call the c++ slot, but the problem is: how should i write the QObject::connect to make the signal in c++ to be accepted from qt c++ syntax?



  • Like this:
    .cpp:
    @
    QObject::connect(obj_schermataCreaNuovaParola, SIGNAL(signal_richiestaSalvataggio(QString , QString , QString , QString , QString , bool )),this, SLOT(salvaBiglietto(QString, QString, QString, QString, QString, bool)));
    @

    in .h:

    @
    public slots:
    salvaBiglietto(QString deutschesWort, QString deutscherBeispiel, QString parolaItaliana, QString esempioItaliano, QString type, bool isImportante);
    @

    qml should use the argument names it finds in the declaration.

    in .qml:

    @onClicked: signal_richiestaSalvataggio {
    console.debug(deutschesWort)
    console.debug(deutscherBeispiel)
    console.debug(parolaItaliana)
    console.debug(esempioItaliano)
    console.debug(type)
    consle.debug(isImportante)
    }
    @


Log in to reply
 

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