Can QT Widgets be used directly with C#?
-
Is there any current language binding that allows this? The 'Bridges' project seems to work only with QML, which I am not interested in (don't like declarative UIs).
I see references to QTSharp, but it doesn't look like it's been touched in the last 10 years. Is anyone out there using it, and if so, does it work with the latest edition of QT?
Thanks in advance to all who reply,
John Bendiksen -
Hi and welcome to devnet,
AFAIK, there's no official binding for C# outside of Qt Bridges.
That said, depending on your needs, you can limit the use of QML to the exact part that needs to interact with C# and do the rest with widgets.
-
Thanks for the quick response, SGaist.
I am a retired Windows-stack developer that has migrated to Linux and re-discovered my joy in programming. I just finished my first big Linux app using Gdk3, GtkSharp and C#. While it turned out great, I don't want to do that again with Gdk. It is so poorly documented, and I spent more time (and code) getting around its limitations then I did doing cool stuff with my own code. The Qt stuff seems much more organized and well-documented.
The GtkSharp library was essentially a C# wrapper for the Gtk widgets, and it worked fine. I was looking for a similar C# wrapper for the Qt Widgets, so I can write my app in C# and leverage the Qt Widgets directly, but the Bridges project does not seem to work that way.
Thanks again for the clarity,
John Bendiksen -
Thanks for the quick response, SGaist.
I am a retired Windows-stack developer that has migrated to Linux and re-discovered my joy in programming. I just finished my first big Linux app using Gdk3, GtkSharp and C#. While it turned out great, I don't want to do that again with Gdk. It is so poorly documented, and I spent more time (and code) getting around its limitations then I did doing cool stuff with my own code. The Qt stuff seems much more organized and well-documented.
The GtkSharp library was essentially a C# wrapper for the Gtk widgets, and it worked fine. I was looking for a similar C# wrapper for the Qt Widgets, so I can write my app in C# and leverage the Qt Widgets directly, but the Bridges project does not seem to work that way.
Thanks again for the clarity,
John Bendiksen@JohnBen you're welcome !
That's correct, the goal of bridges is to provide a mean for people to easily build applications using Qt Quick as the core GUI provider and be able to easily switch the backend.
That said, depending on your needs, you might be able to leverage something like SWIG or maybe Mrbind to generate the bindings you need for your project. It's less ideal but might be workable for you.
-
Thanks for the quick response, SGaist.
I am a retired Windows-stack developer that has migrated to Linux and re-discovered my joy in programming. I just finished my first big Linux app using Gdk3, GtkSharp and C#. While it turned out great, I don't want to do that again with Gdk. It is so poorly documented, and I spent more time (and code) getting around its limitations then I did doing cool stuff with my own code. The Qt stuff seems much more organized and well-documented.
The GtkSharp library was essentially a C# wrapper for the Gtk widgets, and it worked fine. I was looking for a similar C# wrapper for the Qt Widgets, so I can write my app in C# and leverage the Qt Widgets directly, but the Bridges project does not seem to work that way.
Thanks again for the clarity,
John Bendiksen@JohnBen said in Can QT Widgets be used directly with C#?:
I am a retired Windows-stack developer that has migrated to Linux and re-discovered my joy in programming
FWIW: I use/used mostly C# (under Windows) in my professional life. Some C++ but not so much. My use of Qt has been mostly "hobby", and under Linux. I just wanted to say that, while I preferred C# to C++ as a language, I have got along fine with C++ and Qt and Creator. So if you can't find a C# binding you might still give C++/Qt a go and see how you fare.
-
Thanks to both of you for the additional ideas. I had not heard of SWIG and MrBind. I don't know if I can handle any more learning curves right now, though. I'm still working to fully grok the Linux world.
I seem to have painted myself into a corner with my preference for C#, at least as far as Linux development. Which is a shame, as I consider it to be the most generally thoughtful of all programming languages I've picked up over the years.
It seems to get short shrift in the Linux community, however. Probably it's still tainted by its association with The Great Devil (Microsoft).I was hoping that someone with QtSharp experience would chime in as to whether it would work if I settled on Version 5 of Qt, but I can't find anyone actually using it (QTSharp).
Thanks again to both of you. I'm probably going to have to slouch back to Gdk....
John Bendiksen
-
Thanks to both of you for the additional ideas. I had not heard of SWIG and MrBind. I don't know if I can handle any more learning curves right now, though. I'm still working to fully grok the Linux world.
I seem to have painted myself into a corner with my preference for C#, at least as far as Linux development. Which is a shame, as I consider it to be the most generally thoughtful of all programming languages I've picked up over the years.
It seems to get short shrift in the Linux community, however. Probably it's still tainted by its association with The Great Devil (Microsoft).I was hoping that someone with QtSharp experience would chime in as to whether it would work if I settled on Version 5 of Qt, but I can't find anyone actually using it (QTSharp).
Thanks again to both of you. I'm probably going to have to slouch back to Gdk....
John Bendiksen
@JohnBen said in Can QT Widgets be used directly with C#?:
I'm probably going to have to slouch back to Gdk....
Before you do, would you consider giving Qt for Python a chance? It does provide direct bindings, so Widgets are fully supported.
As for the Qt Bridge for C#, for now it will remain focused on Qt Quick / QML. But we would like to also offer support for Widgets at some point. This can be achieved by reusing the interop framework of Bridges to expose the necessary API's as C# types. However, we don't yet have a schedule for the development of that feature.
-
After researching some other products that attempt to do what Qt does, I am more determined than ever to try Qt with C#. I think they have the best approach to cross-platform GUIs.
So I'm going to try the following:
- Uninstall my current Qt V6
- Install Qt V5.14.2 from https://download.qt.io/archive/qt/5.14/5.14.2/
- Install last version of QtSharp from https://gitlab.com/ddobrev/QtSharp
- Try to make things work!
My rationale is that once Qt has their own interface to C# available, the two migrations (QtSharp to Qt's interface, and Qt V5.14.2 to whatever Qt version is current) should be manageable. In the meantime, I get to start coding on my project!
If anyone reading this has any opinions as to whether or not this will work, I'd love to hear them.
Thanks to all,
JB -
After researching some other products that attempt to do what Qt does, I am more determined than ever to try Qt with C#. I think they have the best approach to cross-platform GUIs.
So I'm going to try the following:
- Uninstall my current Qt V6
- Install Qt V5.14.2 from https://download.qt.io/archive/qt/5.14/5.14.2/
- Install last version of QtSharp from https://gitlab.com/ddobrev/QtSharp
- Try to make things work!
My rationale is that once Qt has their own interface to C# available, the two migrations (QtSharp to Qt's interface, and Qt V5.14.2 to whatever Qt version is current) should be manageable. In the meantime, I get to start coding on my project!
If anyone reading this has any opinions as to whether or not this will work, I'd love to hear them.
Thanks to all,
JB@JohnBen
Since you have said this is just a "hobby project" you can do whatever you wish. But be aware that moving back to Qt5 now is a considerable "retrograde" step, I think That QtSharp was never much used/may be flaky, and most significantly was only developed/tested for Windows/MinGW while your target is Linux.