Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Connecting qml complex signal to qt slot
Qt 6.11 is out! See what's new in the release blog

Connecting qml complex signal to qt slot

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    spode
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • lorn.potterL Offline
      lorn.potterL Offline
      lorn.potter
      wrote on last edited by
      #2

      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)
      }
      @

      Freelance Software Engineer, Platform Maintainer QtWebAssembly, Maintainer QtSensors
      Author, Hands-On Mobile and Embedded Development with Qt 5 http://bit.ly/HandsOnMobileEmbedded

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved