ddobrev / QtSharp

Mono/.NET bindings for Qt
Other
571 stars 51 forks source link

QtSharp | SetProperty in QML from CodeBehind #74

Closed djonasdev closed 6 years ago

djonasdev commented 6 years ago

Hello,

I have a problem to set a property from code behind set in the defined in the QML file. Maybe someone could have a look at it.

https://stackoverflow.com/questions/49237167/qtsharp-setproperty-in-qml-from-codebehind

Thanks!

ddobrev commented 6 years ago

I am afraid you cannot at present. The interaction with QML is not added yet.

djonasdev commented 6 years ago

Thanks for your fast reply! Did you plan to integrate this in the near future? What would be your solution approach for a workaround?

ddobrev commented 6 years ago

I definitely hope it would be near but I cannot tell. Integration with QML is a must, no second opinion, but I am just afraid I have been really unable to spare any time on the bindings in the last month. I still have some work to finish for templates and I won't start with QML before that. So any help is welcome. For example, it would help me to know how to theoretically do it. I know PyQt does it by manual tinkering with the meta-object system of Qt but I have still not got to the details.

rose-a commented 6 years ago

Its possible by defining properties in the qml root object and then accessing them via QQuickWidget.RootProperty.SetProperty(), see https://stackoverflow.com/questions/49237167/qtsharp-setproperty-in-qml-from-codebehind

djonasdev commented 6 years ago

@rose-a thank you! It works as expected!

pauldotknopf commented 6 years ago

If you need Qml integration, I am working on a project that does exactly this. I'd consider it usable for production.

https://github.com/pauldotknopf/net-core-qml