Passing parameters from C++ to QML

Viewed 6447

I want to pass some parameters from C++ to QML, so that QML can do something with them.

Somewhat like this:

void MyClass::myCplusplusFunction(int i, int j)
{
    emit mySignal(i, j);
}

In QML, every time that mySignal(i, j) is emitted, I want to call a QML function and do stuff with i and j.

Connections {
    target: myClass
    // mySignal(i, j) is emitted, call myQmlFunction(i,j)
}

How would I go about doing that?

2 Answers
Related