[SOLVED] Receiving signals from QML to C++



  • could you help me to understand why signal_creaNuovaParola(); (from a QML file) does not call the method of the same class creaNuovaParola();, please?
    @
    Gestore.cpp
    void Gestore::visualizzaSchermataPrincipale()
    {
    QDeclarativeView* view = new QDeclarativeView;
    view->setSource(QUrl::fromLocalFile("qml/WoerterErinnerung/main.qml"));
    QObject *obj_schermataPrincipale = view->rootObject();
    QObject::connect(obj_schermataPrincipale, SIGNAL(signal_visualizzaLeggimi()), this, SLOT(visualizzaLeggimi()));
    QObject::connect(obj_schermataPrincipale, SIGNAL(signal_creaNuovaParola()), this, SLOT(creaNuovaParola()));
    view->show();
    }
    @
    main.qml
    @
    Rectangle {
    signal signal_creaNuovaParola();
    ...
    onClicked: signal_creaNuovaParola();
    }
    @



  • Perhaps because a Rectangle element doesn't have an onClicked signal to cause signal_creaNuovaParola to be called. You need a MouseArea element.



  • there is already a mousearea! ;)
    gestore.cpp
    @
    void Gestore::creaNuovaParola()
    {
    QDeclarativeView *schermataNuovaParola = new QDeclarativeView;
    schermataNuovaParola->setSource(QUrl::fromLocalFile("qml/WoerterErinnerung/schermataNuovaParola.qml"));
    schermataNuovaParola->show();
    }
    @


Log in to reply
 

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