any one with qml experiences?
i have idea how to communicate between qml and c++ context in way i like
what can you say?
class FrontendConnectionSide{
Q_OBJECT
Q_PROPERTY(SomeType notifiable READ getNotifiable WRITE setNotifiable NOTIFY notifyBackend)
public:
FrontendConnectionSide(BackendConnectionSide* back){
// connect notify to backend with queued con, without magic
// connect(this,¬ifyBackend,backend,&receiveFunc,Qt::queued...)
assert(back);
back_con = back;
// binded qthread of backend may be different, but if use non direct for backendCon <-> backendModules it is negligible
}
public:
// prop set get...
public slots:
void sendSomethingToBackend(){
// my macros
INVOKE(back, receiveSomethingFromFrontend);
}
// etc...
signals:
//properties signals...
signals:
void receiveSomethingFromBackend();
private:
SomeType notifiable;
BackendConnectionSide* back_con;
};
////
int main(){
BackendConnectionSide* back = ...;
FrontendConnectionSide frontendConnectionSide(back);
engine.rootContext()->setContextProperty("frontendConnectionSide", &frontendConnectionSide);
// connect back slots/signals to logic modules, may be in different threads
}
///////////
Item {
Text {
text: frontendConnectionSide.notifiable // changes will trigger something
}
Button {
onClicked: frontendConnectionSide.sendSomethingToBackend()
}
frontendConnectionSide.receiveSomethingFromBackend.connect(function {
///
})
// or proper style
/*
Connections {
target: applicationData
onDataChanged: console.log("The application data changed!")
}
*/
}```

