Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to convert Qt code in to C#(.Net).



  • How to convert Qt code in to C#(.Net). I want to move the GUI part of my project from QT to some other language but want to call C++ method & function from GUI part.Please suggest the better way.


  • Lifetime Qt Champion

    @prabhat If you don't want to use Qt for your GUI you will need to rewrite your GUI. I don't think there is an easy way to convert C++ code which uses Qt into C# using WPF (I assume here you want to use WPF in C#?).

    But you actually could simply use C++ in .Net with Qt as Qt supports that combination.



  • @jsulm thank you so much for your reply. Could you suggest C# or UWP which will be better and how i can call third party application written in c++ using c#.


  • Lifetime Qt Champion

    @prabhat said in How to convert Qt code in to C#(.Net).:

    C# or UWP which will be better

    These are two different things:
    C# is a programming language
    UWP (Universal Windows Platform) is an environment for applications.
    So, not sure what you're asking.

    "and how i can call third party application written in c++ using c#" - this is unclear. Do you start an application written in C++ in C# (this is possible)? Or do you want to use C++ code in your C# application? And again: you can use C++ to write Qt apps for UWP.



  • @jsulm due to GPL license issue i do not want to use Qt. I have one projcet that is developed in c++ and UI part is in QT. Now I just want to replace QT (UI) part with C# but C++ functionality will remain same.



  • @prabhat
    Don't know what you mean. Nearly all of Qt (all that you should typically be using) is LGPL rather than GPL license. I can't believe that whether you write your code in C++ or C# will make any difference to licensing requirements, why do you think it would? You won't be able to convert the whole of the Qt code base from C++ to C#, and even if you did I don't think that would obviate licensing requirements, you can't take source code with a license and then hand-translate it to a new language and expect thereby to be excused from licensing considerations.

    BTW, https://github.com/ddobrev/QtSharp is still the most supported attempt to do Qt from C#. Have you looked at it (I have no idea how good it is or is not)? It should not remove licensing requirements.



  • @prabhat said in How to convert Qt code in to C#(.Net).:

    due to GPL license

    Qt comes in many different licenses LGPL is probably the most popular and it's not much of a restriction if you ask me

    I just want to replace QT (UI) part with C#

    It's probably easier to just use C++/CLI. it links to the exact same libraries as C# but it remains C++ and allows you to mix managed and unmanaged code in the same project without going crazy


  • Lifetime Qt Champion

    @prabhat As I said: you can use C++ with .Net/WPF. And you can't replace Qt with C# as C# is a programming language and Qt a framework. What you probably mean is that you want to replace Qt with WPF, but there is no need to switch to C# for that.

    And as others said: most of Qt is LGPL not GPL. And LGPL is not so restrictive and usually OK for commercial/closed source software.


Log in to reply