ddobrev / QtSharp

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

Qml / QtQuick #40

Open Hecatron opened 8 years ago

Hecatron commented 8 years ago

This is probably something to be looked at later on for the back burner once we have more of the basic Qt Widgets tested out, but I figured I'd write a bit about it here

The latest QtSharp release now seems to work fine with loading .ui files, and creating widgets. I've not yet tested all the functionality such as slots etc. But one of the things I noticed is that the latest Qt releases now have a drag and drop visual editor for Qml / QtQuick which is sort of Qt's answer to the next generation gui / windows wpf equivilent. https://wiki.qt.io/Introduction_to_Qt_Quick_for_C%2B%2B_Developers

I had a quick go at loading in Qml as a module into QtSharp, but it looks like it needs QtNetworking as a dependency. So I added in QtNetworking to see how far I could get with that this resulted in

d:\SourceControl\GitExternal\QtSharp.ddobrev\QtSharp.CLI\bin\Debug\QtNetwork.cs(16587,28) : error CS0216: The operator 'QtNetwork.QHostAddress.operator ==(QtNetwork.QHostAddress.SpecialAddress, QtNetwork.QHostAddress)' requires a matching operator '!=' to also be defined
ddobrev commented 8 years ago

QtQuick is definitely on my list but since I am forced to work on Qt# in-between because of paid jobs, there will be a while until it's complete. The time-consuming part there is the integration between the host language (C#) and QML, there has to be a way of defining properties and events (signals) in C# so that they are invoked as needed in QML and vice-versa. About QtNetwork, I know about this bug. I have actually already filed it at https://github.com/mono/CppSharp/issues/569, you are welcome to track its progress or even send a patch.

ddobrev commented 8 years ago

QtNetwork works now and is added to my new release: https://github.com/ddobrev/QtSharp/releases/tag/0.0.4 .

ddobrev commented 8 years ago

QtQml has been added: https://github.com/ddobrev/QtSharp/releases/tag/0.0.5 . Thank you for testing, please continue with it.

Hecatron commented 8 years ago

Thanks for adding QtQml support that's awesome

dsoronda commented 6 years ago

Is there any reason why this issue is not closed ?

ddobrev commented 6 years ago

@dsoronda because there's no support for QML yet.

dsoronda commented 6 years ago

well, how about this example ?

Hecatron commented 6 years ago

Some of the stuff within QT uses templates such as

display->findChild<QPushButton *>("bar");
display->findChildren<QWidget *>();

In order for that to work in C# you need to translate it across to generics in C# (same thing but by a different name). But that's not quite in CppSharp yet which is what QtSharp relies on.

so if you happen to use some code that doesn't involve generics / templates then it might work, but you won't be able to use any of the Qt API's that do use generics / templates which may limit what you can do

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

ddobrev commented 5 years ago

@pauldotknopf thank you, I'll definitely have it in mind. I can see you've written your own bridge instead of using CppSharp which makes me a little sad but I still think we could collaborate.

pauldotknopf commented 5 years ago

Yeah, I'm open to a collaboration.

Unfortunately, CppSharp wouldn't work for the QML stuff, since there has to be a native component to work closely with the qml-private headers.