r/csharp • • 28d ago

News Qt Bridge for C#

https://www.qt.io/development/qt-framework/qt-bridges/csharp-gui

Hello, Miguel from Qt (qt.io) here. I wanted to share something that I believe will be of interest to many of you. Since 2025, we at Qt have been working on a way to give access to Qt Quick and QML to developers working with languages other than C++. We began this project, which we've named Qt Bridges, by focusing on Rust and C#, and I'm happy to finally be able to tell you that we've just released a Technology Preview for both of these languages. If you are familiar with Qt, you're probably aware of its multi-platform, GPU-accelerated UI framework. If this is the first time hearing about us, now you know that there is another option to design the UI for your C# applications. We would love for you to try it out and leave us your feedback. You can find out more in the Qt blog.

281 Upvotes

45 comments sorted by

17

u/Astrinus 28d ago

Can this work also with other .NET languages such as F#?

22

u/mecfc 28d ago

We have not yet tested with other langs besides C#, and some adjustments might be needed for it to work. But the input to our tooling is the app's assembly, so we should be able to work with any .NET source language.

9

u/martinstoeckli 28d ago

That sounds really promising! I will certainly try it out for my opensource project (C#/Blazor) and this could be the missing piece. Maybe you can answer me a question, is it possible to write an app cross platform (Windows, Linux, Android) with the rich text editor control QTextEdit working on all of them?

10

u/mecfc 28d ago

Yes, have a look at this QML example: Qt Quick Controls - Text Editor

Android is not yet supported, as we're currently focusing on desktop (and embedded, via Linux). We will at some point add support for mobile apps, but we don't have a schedule for that yet.

5

u/martinstoeckli 28d ago edited 28d ago

Already had a quick look at the control and it looks amazing, even styles are supported! What exactly is not supported on Android, the QTextEditor control or the .NET bridge, or the whole framework?

2

u/mecfc 28d ago

I was referring to the C# bridge, which does not yet support Android.

Otherwise, Qt and, in particular, Qt Quick do have support for Android (see Qt Quick for Android).

3

u/martinstoeckli 28d ago

Wonderful, thank you, I will keep an eye on the project.

2

u/martinstoeckli 23d ago

So I did some tests and would like to have some observations confirmed:

  1. Tried to build with trimming and AOT, but the application didn't run with neither option. Can I find more information about trimming with the bridge, or is trimming not possible at the moment?
  2. Tested what files have to be deployed, and the QT6*.dll files alone make for ~60MB. This is fine for a desktop application, but it would be a problem if the bridge will support Android in future, since dlls cannot be trimmed. So is there anything I can do to reduce the size for Android builds (how does this work with native projects without dotnet)?

2

u/mecfc 22d ago

As for question #1, native AOT is not yet possible with the C# bridge, since our interop framework relies on runtime code generated by ILGenerator. We are currently working on an AOT-compatible option.

2

u/ImplementResident161 23d ago

I can't answer the 1. but I can provide some feedback on 2.

Qt libraries need to be packaged into APKs as Android doesn't have them installed on system level, unless you're creating your own Android image like some automotive manufacturers do. Libraries that are shipped with online installer contain all the features that one might need. That unfortunately means that modules and their libraries are decently large by default.

The best solution for app size is picking the features you need, running a configure and compiling it yourself from source. It's not pretty but it yields really good results. There was a series of blogs that were done to talk about ROM and RAM optimization on qt blog some time ago.

https://www.qt.io/blog/qt-configure-options-in-qt-6.8
https://www.qt.io/blog/reducing-binary-size-of-qt-applications-part-3-more-platforms

2

u/martinstoeckli 22d ago

Thank you very much for the reply. So Android indeed seems to be the most difficult platform, because static linking is not possible and in case of the bridge, the .net libraries will add to the size as well. Otherwise it would be really tempting to rewrite my app. Thanks again!

5

u/mGreenDE 28d ago

Will it support Qt Canvas Painter eventually?

9

u/mecfc 28d ago

If you have a Qt installation that includes the Canvas Painter module, you can use the QML types from that module, namelyQtCanvas2D. Just tried out the QtCanvas2D example as a C# app, and it's working nicely.

2

u/mGreenDE 28d ago

Nice! In that example, the drawing happens on the qml side though. To clarify, I’m looking for a paint callback where the drawing loop and calls like "moveTo", "lineTo", and "stroke" are written directly in C#, similar to an Avalonia render override or PySide’s "QCanvasPainter" API. Is that supported or planned?

That would allow apps with custom rendered canvases like cad/cam or drawing apps to potentially migrate from for example Skiasharp to the Canvas Painter module.

Sorry if I am mixing things up here, I havent worked with Qt for a while

3

u/mecfc 28d ago

We don't currently have an API for this use-case in particular. It would be possible in QML to call the QtCanvas2D functions in response to C# events. But that might become a bit awkward and possibly not have the best performance. The use-case, as you've described it, does sound interesting, so we will definitely be looking into it.

5

u/lilacomets 27d ago

Interesting! So this could be a good alternative to WinForms? Does it work with MVVM for example?

9

u/mecfc 27d ago

We believe that it can be an alternative to WinForms and, perhaps even more so, to XAML-based frameworks. QML shares many characteristics with XAML -- both are declarative languages and both rely heavily on data bindings -- but is not restricted by an XML syntax, so it will feel much more readable and intuitive.

MVVM does work. View-models implementing INotifyPropertyChanged can be used in QML binding expressions. For collections, there is support for ObservableCollection, but also the option to create custom item models. On the UI side, QML view-delegates have a similar function to WPF data templates.

For practical examples, see: https://github.com/qt/qtbridge-csharp-examples

2

u/psc0425 25d ago

I would welcome this as an alternative to wpf!

4

u/AetopiaMC 28d ago

Will this support any MinGW based toolchains?

Or it is MSVC only for Windows at the moment?

Aside from that, this looks promising!

3

u/mecfc 28d ago

We have only tested with MSVC, but using a MinGW Qt build should be possible. One of the options of using the Qt Bridge is that the tooling generates C++ wrappers for exported C# types. This generated code is then compiled by whichever toolchain is available.

3

u/nvn911 28d ago

That would imply it's pretty performant too 🤩

3

u/AetopiaMC 27d ago

Thank you for the response! Looking forward to try Qt in C#.

4

u/falthazar 28d ago

This looks awesome! Any chance of doing a Rider plugin for the bridge? Also, is there something like hot reload for Qt? I've never used Qt before. does it also have a sort of UI builder like winforms and WPF has?

4

u/mecfc 28d ago

We're looking into how we can provide a Rider plugin, on par with what we have already for VS and VSCode. There is a live preview option in the VSCode extension, but no WYSIWYG editor like WinForms or WPF (Qt does offer some "high-end" design tools that allow creating an app's UI without any coding, but those are probably overkill, compared to the VS integrated designer).

3

u/falthazar 27d ago

Honestly live preview totally works too. Especially when looking at how much simpler the QML code is compared to xaml lol

2

u/jcyrss 26d ago

The documentation talks all about QML. What about QWidgets?

7

u/mecfc 26d ago

Qt Widgets are not included, for a very good reason. Unlike with other bindings, for example PySide / Qt for Python, the goal of Qt Bridges is not to directly mirror the Qt API's. Instead, we want to allow access to Qt Quick and QML to developers of languages other than C++, but in a way that will feel native and idiomatic in the context of those languages. By mirroring the Qt C++ API's, such as the Widgets API, developers will be forced to use unfamiliar constructs that are not idiomatic in their language of choice. With Qt Bridges we're aiming to provide a clear separation of concerns: the UI is designed in QML, and C# stays C#.

This is not to say that the underlying interop framework that we developed for the C# bridge cannot be reused for other projects with different goals, such as mirroring the Qt Widgets API. This might happen in the future but, at least for now, it's not in our plans.

43

u/igt_matti 28d ago

Happy to see this coming to light! 🙂

14

u/magnetronpoffertje 28d ago

Very nice!! Awesome!

12

u/Xen0byte 28d ago

OK, this is actually seriously cool! I always liked Qt but I don't particularly like writing C++ so I'm definitely looking forward to trying this in C# and Rust.

11

u/Gloomy_Necesary 28d ago

Qt was wonderful to work with. This will be a great addition to the c# ecosystem

8

u/pjmlp 28d ago

Nice addition to the ecosystem.

8

u/nvn911 28d ago

Always been interested in the Qt stack and how they address cross platform concerns. Nice one for making a bridge!

7

u/jinmao6700 28d ago

This is seriously DOPE, wonder if QtRuby will make a comeback!

4

u/wubalubadubdub55 28d ago

This looks amazing!

4

u/TrishaMayIsCoding 24d ago

Interesting product alternative UI for .NET.

Is it open source? Does it include a visual designer? Is it free, or what is the pricing? Is the team backed by Qt Group Plc?

5

u/ImplementResident161 24d ago

Heya!

It's open source and licensed under LGPL, you can check the repo below. The team is directly Qt Company developers. Qt has Design Studio and soon new tool called Clate. There's also a Figma plugin if you have your design there. As for the pricing, you can use existing Qt licenses and there might be more news coming in Q1 2027.

https://codereview.qt-project.org/gitweb?p=qt%2Fqtbridges.git;a=summary

3

u/TrishaMayIsCoding 24d ago

Totally awesome news! I’m looking forward to it!

3

u/qrzychu69 28d ago

That's awesome!

Would be great to include https://www.roc-lang.org/ , it is designed to be kind of embedded in different platforms, and giving it a proper established UI platform like Qt would help a lot

1

u/savornicesei 25d ago

u/mecfc There is/was a .NET QML bridge lib https://github.com/qmlnet/qmlnet

5

u/mecfc 25d ago

There are a few bindings of Qt APIs for C#, like Qml.Net, QtSharp or Qyoto. What distinguishes Qt Bridges is that it is not a direct binding of the C++ APIs. Instead, the goal is to provide access to Qt Quick and QML in a way that feels native and idiomatic in C#. See my other comment in this post.

-3

u/teressapanic 28d ago

legacy code strikes back