The easiest way to add a GUI to a C ++ application

I am creating numerical software in C ++ and want to add a graphical interface (mainly for Windows). I know how to create graphical interfaces using convenient editors in modern languages ​​such as Java or .NET. Now my question is what is the easiest and most convenient way to add a GUI for my program. I am completely free to choose tools (open source and portability would be nice), but please keep in mind how much code and template interfaces you need to support if the GUI is implemented in another language (for example, C #).

Please do not suggest switching the entire project with C ++! Please note that the program does not require much interaction between C ++ code and the graphical interface.

+7
source share
8 answers

The C ++ ISO statements in the comments of this answer are poorly edited. None of the solutions presented here would impose on the computing code the requirement to switch to another C ++ dialect. The GUI code itself may be a different story.

Answers about using Windows Forms with managed C ++ are probably the most practical. Most of the code associated with the user interface will be in C ++ dialect (extension), where pointers collected using .NET garbage will live with traditional C ++ ISO pointers. I have not used this method, but from what I read, it may be better than what I used.

MFC can be more practical if you do not want to invest in .NET for this task. It uses standard C ++ constructs to port the Windows API. The Windows API uses a specific calling convention that C ++ usually does not use, and it requires an extension for C ++, but this is no different from how a C ++ program calls some functions that are external "C " Visual Studio has a GUI layout tool that is really good at linking dialogs and interacting with dialog widgets with variables that reflect the state of widgets. I used this. If you can drop your GUI into a dialog box, that would be a great option, otherwise you would use one of the windows controlled by MFC layouts.

Obviously, the above options do not handle other platforms that you might think about.

There are also various tools that were born on other platforms and were decently ported to Windows. GTK, QT, FLTK and WxWindows come to mind. I have not used any of the dialog layout / application development tools that work with them, and I have not used QT at all. The last time I looked at QT, it had a special preprocessor code for the GUI code. As far as I know, these portable toolkits are pure C ++ ISO.

As a really-out option, you can program the X Window System protocol with "libx". As far as I know, this is not related to code other than ISO C ++.

+6
source

Qt is a decent choice. It is stable, has a wonderful C ++ interface (unlike MFC) and has a convenient tool for developers.
The overhead associated with learning this from scratch may be more likely that you are willing to invest. He has a certain learning curve.

+6
source

wxWidgets would be a good choice for cross platform GUI for C ++

+4
source

As much as I like C ++, it's hard to create a graphical interface with it. I would create a quick C # WinForms application that would allow you to use things like Visual Studio visual designers (drag and drop buttons, etc.) and invoke your C ++ application using P / Invoke.

C ++ often creates smoother and nicer GUIs, but this requires a bit more work.

+3
source

If it were just a simple graphical interface consisting mainly of standard controls, I would do it with MFC. It may be outdated and has never been really good, but it is still useful to quickly and quickly launch your own Windows GUI.

+1
source

I need to grin at all the cat's ways of this cat. Life is good. My answer is a product that I manage. XVT can do it for you. The easiest way is to let us do this for you or give you a template to get there. It is just a question of whether you have more money than time. Then I will look at us. This would be the fastest and least effort on your part.

+1
source

The MFC Dialog Based app can meet your needs.

0
source

Depending on what you need, there is a good imgui made by Mikko floating around, which you can just plug in and use pretty quickly. This is done in opengl, although it will not be your standard windows-gui, but it is very small and very easy to use. You can download the r'lyeh version: http://code.google.com/p/colony9/source/browse/include/goo/imgui.h .

This is the easiest and most convenient way that I know, it depends on the SDL.

0
source

All Articles