Integrating Qt GUI code into C# - c#

I have to develop a plug-in for an external program using C#.
I am an experienced Qt/C++ programmer and the core of the plug-in is programmed in C++.
My first idea was to program GUI in C#, which write settings to a text file and then call the core C++ code, as an external process, with this textfile as an input.
However I also noticed that there is something called the QAxServer Module in Qt that should make it possible to run Qt/C++ GUI code from C# (trough ActiveX).
I experimented a bit with this and it seemed a bit "shaky".
Do you have any experiences with this you could share?

I would look at writing a C++/CLI (i.e. Managed C++) shim to launch your plug-in and be the bridge between it and the main application.
This will allow you to call into (or be called from) the C# application on one side and talk native C++ on the other.

http://techbase.kde.org/Development/Languages/Qyoto
Qyoto seems to be the most active Qt binding for .NET.

There is also the "QT for .NET" project.

Related

Xamarin and c++ code

Currently I`m exploring how to write mobile apps for Android using Xamarin and C#. Also I have some c++ libraries(and source code for them) that should be used in application. These libraries are responsible for communication via internet(just to say).
So it is possible to use this c++ code in xamarin.android project? Or it should be rewritten in c# to be used?
Im not sure with networking but most C++ code can be used 100% in Xamarin.
If it works, you can't be sure if it works correctly in every situation on IOS.
We had the same problem with using UDP Sockets for VOIP(C#).
Most of the time it will work, but in case of VOIP you need to use iOS sockets so you can set them to a special mode so they won't be closed when the app gets paused.
So it depends on what you want to do and how the C++ code is written.
Im not sure if you can use normal unix sockets when using C++ on iOS but that should be the only problem when using it.
Just checked: Does Mac/IOS use the same sys/socket.h as the Linux kernel?
I think, if your library uses BSD sockets everything should be fine.
Usually it is possible to call some code in any other library unless
It exports the functionality
There is a wrapper in your language to make use of that exported functionality.
I do not know much about this Xamarin thing but I guess you should see if the library is binary compatible not code (i.e) that compiles with the source of your C++ project and you can make calls to it from your C# program.
Also while checking the Zamarin library documents, it seems that not every piece of C# code can be used on Xamarin platform. Please check the Xamarin community and the forums for more in details.

Host Windows Forms (C#) Inside MFC Application (VC++,VS6.0)

After a bunch of reading this afternoon, and not getting any tangible results. Is it possible to host a windows forms dialog inside of a MFC application that is still being developed using VC6.
The issue arises is that we have a large application that has never been upgraded with the new Visual Studios because VC6 always worked. Now we need to add some of the C# functionality in it. I am unable to do the /clr option as our project consists entirely of unmanaged C++. I did a search for "CWinFormsControl" within all our libraries/headers and didn't come up with anything. I am unsure what to try next.
Also, forgive any ignorance as I am doing research and new to this depth of programming.
I have checked the following articles:
http://msdn.microsoft.com/en-us/library/676cbawx(v=vs.100).aspx
http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/97fddc35-e94d-4587-8be0-0b573185eb63/
http://msdn.microsoft.com/en-us/library/ahdd1h97(v=vs.80).aspx
http://www.functionx.com/visualc/Lesson04.htm
http://social.msdn.microsoft.com/Forums/sk/vcgeneral/thread/c38db22e-cf61-4b47-bcc8-e6202c40d1b5
CWinFormsControl requires MFC 8.0.
You can make your managed assembly a COM server (e.g. ActiveX) and use it in MFC application like any other COM server.
I don't have VC6 laying around to try this out, but I think it should be mostly possible; at least for a simple modal ShowDialog() scenario.
You'll create a new assembly/DLL using C++/CLI, compiled with the /clr flag. This will expose an unmanaged API to your existing MFC code, using the usual __declspec(dllexport). The implementation will call into your C# code which lives it yet another assembly.

WPF with C++, is it possible?

I have my main program in C++, but now I need to build a beautiful application and I know that WPF is easy and makes for beautiful apps. Can WPF work with C++ or C# and C++? (If yes, how?) Is WPF the best thing for me?
You can use WPF in a managed C++ project, but you're better off keeping your C++ in a separate assembly and referencing it from a C# or VB WPF project.
Yes, you can develop a GUI using WPF framework in Managed C+ or C++/CLI. But they're not Standard C++, hence not cross-platform.
If you just want a GUI for your application written in C++, then you may try Qt as well. The advantage in Qt is that its completely in C++. Not Microsoft Managed C++. The second advantage is that its cross-platform toolkit. That means, you can run your app in Windows, Linux, Mac, and on other machines as well.
Have a look at its documentation
Qt Reference Documentation
It has lots of tools for fast development such as Qt Creator, Qt Designer and others. You can see all of them by browsing the above link.
WPF is dead along with Silverlight, remember, MS says its HTML5 only from now on :)
Using WPF in your C++ app can be achieved using hwndSource, but its not the optimal solution, for that you will have to create C# or VB.NET GUI app, and use it to communicate with your C++ app via some form of IPC.
There are alternatives, probably the best one is to write your GUI using Qt, which is very well respected. You can get similar features to WPF by writing using QML alongside the old forms-based system (which means you get all the development speed of using the old, boring text boxes and the like, and the fancy GUI benefits of using the new declarative UI system, all in the same system. sweet).
Of course, a decent option is to make your app into a back-end server process and call it from a web-server based HTML5 UI. That's pretty future proof, easy to deploy to clients, and as modern as you're likely to get.

Using C# to make Application for Maemo (convert code to QT)

I want to make an application for my phone (Nokia N900) It uses the Maemo Platform, which is a Linux variant. Most applications are made with either QT or Python, i only have experience in C#, and am wondering if it is at all possible to convert C# to QT, or would i have to use something like Mono or Vala to write the code in C# and create the applications for the N900??
Cheers,
Brendan
About "converting C# to Qt": they're not comparable: C# is a language, while Qt is a UI framework.
Mono does run on Maemo and while there are Qt bindings for .Net/Mono, Mono uses Gtk# as the default/recommended/supported UI framework.
If you are already confident with C#/programming in general, then it should not be too much trouble to pick up a new set of tools. One size does not always fit all!
I do not think that exist a tool for convert C# code to the equivalent Qt/C++, Qt/Python, is something that is best done manually. It's best developed on a platform like a Mono for the N900 or find someone with knowledgeable in Qt able to carry out the work.
Note that Qt is the default platform for Nokia, if you want to install this application on other devices easily best using Qt.
C# as a programming language is controlled by Microsoft. While Microsoft has stated that they will provide a "patent convenant" regarding C#, it is hard to believe them since they have been so eager to sue in the past. ;)
If you want to "convert" your C# app, you'll need to incorporate it into Mono. Mono is a 'cross-platform, opensource .NET development framework." http://www.mono-project.com/Main_Page
Once you've got your app working in Mono, you'll need to interface into Maemo. There are a couple of routes to do this, but Qt is the most likely one to choose. It might be so much work to port your app to Qt that you decide to re-write it, fortunately Qt supports a number of programming languages so you may be able to find something similar to Mono if not Mono and C# itself.

What is the best way to use a Custom .net control from a legacy C++ app?

I maintain a legacy application (unmanaged C++) and I need a new control (Basic Form). I would like to build this control in C# for simplicity but use it from my legacy app. Any suggestions?
Well, you might want to make a COM control in C#, register it and use it from within your C++ application. I can't see any other way of using a .NET control in C++ - however, I haven't tried that.
Theoretically you could build the c++ into a dll and use it, but there is really not enough information here.

Categories