8

As a learning C++ programmer, I am trying to select a GUI framework or library for my own projects.

I have some experience with Qt: it's very straightforward, it has a very good documentation, and provides a lot of tools, but it seems to duplicate a lot of the standard library.

Are all C++ GUI libraries like this? What should I be looking for in a GUI library? How do I determine which one would be best given a particular problem? Should I focus on one specific library, or is it worth it to know several of them as they might serve different purposes?

1

5 Answers 5

6

Qt: it's very straightforward,

Not something that is generally true of gui libs, but Qt's signal/slot mechanism is a pretty good solution

it has a very good documentation,

Qt and WX both provide pretty good docs, both reference and tutorial

and provides a lot of tools,

Qt needs tools, other libs don't require anything beyond the regular compiler - especially those that use sizer type layouts don't even need a gui editor.

but it seems to duplicate a lot of the standard library.

This is common simply because only a couple of years ago you couldn't rely on std lib and the STL being present or functional on all platforms. Even today this is always true on mobile platforms. Often though you don't HAVE to use their collection classes, or you find they are plug compatible with the stl ones

How do I determine which one would be best given a particular problem?"

Generally you need a gui lib to do either standard desktop big-app type problems or a highly configurable mobile/web interfaces. Often the gui lib has a flavour for both, such as Qt and QWT

4
  • Duplicating the standard library happens a lot - including wxWidgets, though IIRC there are options to switch to using the standard library now. Microsoft didn't get serious about the standard until probably the 2003 version of Visual Studio, among other issues.
    – user8709
    Commented Jul 3, 2011 at 0:51
  • Don't think it was completely correct until VS2008! It's a few years since I used wx but on Qt the collection classes are now completely switchable for the stl. They both still use their own string class - but given how poor std::string is you can forgive that! Commented Jul 3, 2011 at 1:29
  • I doubt it's completely correct even now - perfection is a bit much to ask for. VC++2003 seemed mostly OK to me, though with some nasties. Maybe it's an (anything's better than Visual C++ 6) perspective things.
    – user8709
    Commented Jul 3, 2011 at 1:56
  • @Steve314 - it got a lot better in vc2008 and now vc2010. It looks like by hiring stutter msft's C++ team have moved from the "it works for us" and "add a feature to the language to fix this app" to trying to be the best C++ compiler. Commented Jul 3, 2011 at 16:49
4

Are all C++ GUI libraries like this?

Don't try to wrap everything into one descriptor. There will always be libraries that are poorly or even undocumented. They might reinvent the wheel 90% of the time or provide some new groundbreaking functionality.

What should I be looking for in a GUI library?

You should look for a library that solves your needs in the most efficient way possible. By efficient I mean a combination of code-wise and performance. Obviously if the library looks reminiscent of obfuscated Perl you wouldn't want to use it for production code even if it provides extremely fast execution. Conversely you don't want something extremely verbose but with a hindered execution speed.

How do I determine which one would be best given a particular problem?

There isn't always a definitive way to determine what is the best X to do Y. If you can find some kind of non-biased data in regards to your problem and the solutions offered by the libraries that is one way. Knowledge and experience are also among the best ways to determine how a solution will fit your needs.

Should I focus on one specific library, or is it worth it to know several of them as they might serve different purposes?

That is solely dependent on what you do and what your needs are. If you need to work on X then you would need to learn the best library for it. If you are only ever working on one thing and you have one library that suits your needs, why bother?*

*Note: It never really hurts to know more, I'm just saying from a purely "Getting the job done" standpoint.

1
  • +1 "getting the job done". You could spend a lifetime researching the best possible GUI lib for your particular project, and at the end you'd probably only choose one marginally better (if at all) than you would choose from a fairly superficial examination of the most popular few. Personally, I know enough wxWidgets that I'm unlikely to bother researching anything else as long as I can control which GUI I'm using - QT or GTK can probably be treated the same way, assuming using them in Windows isn't a big deal. If anything, I'm curious about the lightweight FLTK library.
    – user8709
    Commented Jul 3, 2011 at 0:48
2

How do I determine which one would be best given a particular problem?

Having done dozens of GUI ports and cross-platform GUI apps since 1989, I've found the first question you must always decide is look-and-feel. Cross-platform GUI libraries run along a spectrum that way.

Similar look-and-feel everywhere

These work best if your software is aimed at people who have to change platforms frequently, and want their software to behave identically everywhere. This is common in some scientific applications, where you might be a Linux person visiting a Mac lab, or somebody gives you a ton of Windows boxen as part of a grant.

Examples of such libraries would be Tk and GTK+.

Platform native look-and-feel everywhere

These are much better for commercial applications and non-technical users, because those folks are much more interested in a familiar user interface. In fact, they're likely to refuse to use software that doesn't have a native look-and-feel.

Examples of such libraries would be wxWidgets, RealBasic, Cocotron, and Qt.


Once you make that decision, then you can start looking at your problem domain in more detail and determine which particular toolkit will be the best fit.

3
  • Isn't possible to set the look & feel once and for all with wxWidgets or Qt ?
    – BenjaminB
    Commented Jul 3, 2011 at 14:18
  • My recollection is that wxWidgets is a wrapper around the platform native UI system, so I don't think so. I'm not sure about Qt. They used to emulate native widget look and feel, so you could switch it to emulating a different platform. But I'm not sure what they're doing now. Anyway, my experience is mostly with developing for commercial use by non-technical customers, where a non-native look-and-feel is a bad thing. For instance, whenever I fire up the Tk-based git gui, I find it a little jarring because no matter what platform I'm on, it looks wrong.
    – Bob Murphy
    Commented Jul 3, 2011 at 16:42
  • Both wx and qt either use native widgets or draw native looking widgets if they don't exist, both support themes so look native. Commented Jul 3, 2011 at 16:56
2

Beneath the technical aspects you should have a close look at the licensing. Qt is only free for non commercial open source development. If you start to use it in other areas like contract work you must make sure that you and your customer or company can use it and that the costs are acceptable to all involved parties.

edit: As Raphael says I'm wrong about Qt's license. Still I think it's an important part of the decision process for a GUI library someone may want to use, to make sure that he can do this in a legal way.

1
  • The license has changed. As long as you don't modify Qt's source you can use it for free even on commercial, closed-source applications.
    – Raphael
    Commented Jul 3, 2011 at 16:41
1

Aside form the technicality of the choice, another point is the availability of developers with knowledge of the chosen tool, for the life of the product. This should be a primary driver in choosing all development tools in the commercial world. If it's just for you, then do what you want, however if not, stick to a tool(s) that developers know, want to know, and are well known ones. It's a lot easier to recruit a contractor or employee for a Java/Swing or C++/QT app than an ADA/(fill in your unheard GUI toolkit here) app.

Is the toolkit you choose "career advancing" for you and everyone else, or would it be a liability on a resume?

1
  • I am not responsible of anything but myself. So it is just for my personal projects and my resume!
    – BenjaminB
    Commented Jul 3, 2011 at 23:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.