24

First, I know this is kind of common question, but I could not find the exact answer I am looking for.

I have done many projects in Java using Swing. Starting by just coding the GUI, then later moving onto GUI designers. This proved to be a very quick and easy way to build GUI apps.

But now, I need to move to C++. I am beginning a project which uses a lot of HW resources (DirectX, OpenCV, etc...) I know there are Java libraries for these technologies. However, C++ is definitely the right way to go, considering the internals of this project.

I know C and C++ languages well from MCU programming. Also, I have read many articles on native WinAPI programming, Windows internals, etc. I think I have enough knowledge to start. I don´t want to worry much about GUI design, but it must look appropriate.

I know there are few basic options: Pure WinAPI, MFC, WTL, Qt... I would be very glad if there were some kind of GUI designer tool, but from my research, there is not. There is the MFC wizard which helps to create a basic window, but it is not a designer. The closest thing I found was Qt. But from what I read, it is not using WinAPI for drawing, for in future look and feel of Qt written app can differ from native Windows look.

So, to summarize, please, if you are experienced with creating native Windows C++ Apps with GUI, what would you recommend to me? Specifically, is there any tool or designer I missed?

(I am using Visual Studio 2010 professional, since I have it free thanks to the DreamSpark project)

herrpark
  • 53
  • 1
  • 4
B.Gen.Jack.O.Neill
  • 8,169
  • 12
  • 51
  • 79
  • You really don't unless you are a glutton for punishment... use MFC. – Ed S. Mar 15 '12 at 23:45
  • 8
    I am actually quite surprised thant "world" moved to managed code solutions and basically stopped native GUI development... There are still field where native is best way to go... – B.Gen.Jack.O.Neill Mar 16 '12 at 00:07
  • If you like conforming to Microsoft's coding style and interfaces, use MFC. Other popular GUIs are QT and wxWidgets. If you're really agressive and efficient, use the native Windows API (very painful). – Thomas Matthews Mar 16 '12 at 00:11
  • @ThomasMatthews is right, QT is great. – Ed S. Mar 16 '12 at 07:24
  • possible duplicate of [What is the best library to use when writing GUI applications in C++?](http://stackoverflow.com/questions/5061877/what-is-the-best-library-to-use-when-writing-gui-applications-in-c), [Qt alternative? (windows only)](http://stackoverflow.com/questions/5685824/qt-alternative-windows-only), [Gui toolkits, which should I use?](http://stackoverflow.com/questions/584734/gui-toolkits-which-should-i-use) – Cody Gray - on strike Mar 17 '12 at 09:00
  • Yeah there's really no good solution. This is kind of my soapbox. A lot of people like Qt, but you're right, it's *not* native. As In silico says, it does use OS theming APIs to draw the controls, but they don't always *behave* like native controls. There are a lot of gaps in the functionality. It's little things, so a lot of people don't notice, but *I* do and so will your users who are used to those things being there. I learned the Win32 API and use that. There's no designer, but it's native and it's really not that bad. I'm also working on my own easy-to-use wrapper; you might do the same. – Cody Gray - on strike Mar 17 '12 at 09:04

7 Answers7

9

I recently used Qt4 and was very pleased with the API. I found it straightforward, well documented, and the code is extremely concise.

Qt does an extremely good job of emulating the target OS look and feel (as @In silico pointed out in the comments, Qt actually draws everything itself and does not use native components) Regardless, this can be coded by hand or visually through the GUI editor in their IDE, Qt Creator. If you go this route, I recommend creating your initial GUI project (.pro file) there, then importing it into Visual Studio via the Qt Visual Studio Add-In.

Slots and signals, Qt's event/messaging system, is also worth mentioning. Yes, it's critical to GUI programming, but could also be extremely useful in lower-level code.

I expect Qt would work well in your project, but as always, create a few simple tests to ensure the technologies will work together feasibly.

Courtney Christensen
  • 9,165
  • 5
  • 47
  • 56
  • Yep, QT is the best of a bad bunch. :D – 111111 Mar 16 '12 at 00:42
  • 1
    @zourtney: Technically it doesn't use native components, it draws everything itself. It looks native because it uses the operating system APIs to get system theming information. – In silico Mar 16 '12 at 04:57
  • 1
    @In silico, Ack! Thank you...it seems I jumped to conclusions when I read through the docs a fews months back. Answer amended... – Courtney Christensen Mar 16 '12 at 05:23
  • Qt is nice and easy, but I personally believe that it would never replace the place of Win32/MFC. –  Sep 27 '13 at 06:49
  • 1
    QtGui is ok for simple application (no custom controls and not so much of performance isssue). The moment you want to do complex professional work it is horrible. Stay away from stylesheets because are really slow and work in a confusing way with the existing attributes. I speak from experience here. I wish i never started with QtGui. I am currently looking to replace QtGui. – mhstnsc May 23 '14 at 08:25
4

Here are a few hints:

  • Don't lock yourself into C++. C# and Java (for instance) can be easily interop'ed with C/C++. (Through PInvoke or C++/CLI for the former and JNI for the later). C++ may not be the ideal language to write a GUI quickly.

  • Your requirement for "native windows look" is arbitrary and you should think it over. Is that really what you need ?

  • Winforms. It's an older technology but is still widely used. You use the API from C++/CLI or C# (or any .NET) language.

  • WPF, a more recent API but that will be harder to deal with from C++, (better with C# or VB)

  • One of the many GUI toolkit available on the market that have a C or C++ API (QT, GTK, wxWidgets, the VCL, ... list here). Some have "native" looks, some don't. Some have designers some don't. Some are free, some aren't.

J.N.
  • 8,203
  • 3
  • 29
  • 39
  • 2
    I can only speak for C#: Interops can be a nasty business. Especially how you can't return a marshalled value, so you deal with pointers, and just through `IntPtr`s so you need to remember/comment the types, allocating and freeing memory, use a static copy, etc. Just working with a list of strings has been pretty annoying for me and that's just two levels of pointers. Also C++ has name mangling which can confuse newcomers, you have to match calling convention, match cpu architecture, etc. etc.. I can agree that when working with just primitives it's not bad at all, even very very easy. – MasterMastic Aug 09 '14 at 09:28
4

If you need simple user interface i recommend use WTL - is simple, lightweight, header-only library, very good wrapper over WinAPI. In Visual Studio you can use form designer for creating windows and use WTL classes for implement interaction with user. WTL have poor documentation but WTL is looking like MFC.

If you want rich possibilities i recommend use Qt. It's very powerful GUI framework with great community.

Torsten
  • 21,726
  • 5
  • 24
  • 31
3

You can use the C++Builder XE2 (Part of the Rad Studio IDE), which includes the VCL (Visual Component Library), the VCL is a wrapper over the Windows controls (and also includes custom controls) which increase the development productivity.

RRUZ
  • 134,889
  • 20
  • 356
  • 483
3

The wxWidgets c++ class library comes with a screen builder.

high5
  • 471
  • 5
  • 7
2

VCL is a good way to go. It has a GUI designer tool (Embarcadero Rad Studio XE6) fully native gui developer for C++ and Delphi

1

Depending on how strict your definition is, you could use .NET Windows Forms or Windows Presentation Foundation and plug logic in from C++, C++/CLI, and C#. That would not be a pure C++ solution. In fact, I wouldn't even necessarily advise using C++ in that situation. Simply using C# would be more intuitive and maintainable. WinForms and WPF have pretty awesome GUI designers though.

Sion Sheevok
  • 4,057
  • 2
  • 21
  • 37