API for C++ GUI Programming

Hi all and thanks in advance.

Can you suggest me an API to realize a GUI with C++?? I try to create a simple project with win API but I see that there's a lot of code to create just a simple window with a title. I've even read in some topic that win32 api are obsolete and are only win compatible.

I have heard something about WxWidget and Qt4 but I don't know wich is the easiest and better approach.

I would like something like javax.Swing, I'm a java developer and I study C pure at college but I never realize a real application in c++ (and I forget many thing of this language!!). Now I'm restart studing and any suggestion will be appreciated.

Thanks a lot and sorry for my english

Last edited on
No idea??
What do you think about Qt or WxWidget? Wich is the better OO approach??

Can someone suggest me please?

Thank you
closed account (3qX21hU5)
It really all depends what one you like the feel of better. Both QT and wxWidgets are great APIs.

I would suggest downloading both of them and try them out. Give it a bit of time though, most likely you won't know which one you feel more comfortable with till at least a few weeks of using them.

Now that I have said that I will say that I personally think QT is superior in almost every way ;p. I think this SO post sums it up quite well.

I've had experience with both but more with Qt than wxWidgets.

The problems with wxWidgets is that it tries to be more like MFC than Qt. wxWidgets was made to help users that was using MFC to migrate easier to a better and less buggy GUI framework. So what wxWidgets made actually inherited a lot of the bad things MFC had. And what you got was wxWidgets.

wxWidgets still believes in making the framework work on Windows 95, Windows 98, Windows 2000, etc. They still offer a ANSI and a Unicode choice. Which, I believe, is stupid because no one IMHO still lives in a world that only flows around ANSI. It should be Unicode and only Unicode.

The building of wxWidgets is just complicated at best. You have to edit some god forsaken header file to enable features and even that it is badly documented and overwhelming.

Most classes lack functionality. No proxy support in the socket library, not many notifications and if you have to, more than likely have to do it yourself (awful in my book).

You still have to manage enums for what is what. Like IDL_ITEMVIEW as you would in Win32 API and MFC.

The documentation is not as good, it's hard to follow anywhere in it.

The design is based on Dev-C++ which was a horrible IDE and never maintained at all. While it does fix it up some, it still lacks anything worth using of it. It also inherited the bad things like no code completion, bad debugger, ugly editor. But it did add a good designer for wxWidgets. But AFAIK no support for Linux or Mac.

The good points of wxWidget is that it works on every platform, and if you are using MFC and like the message maps and still need to support old OS's like I said above go for wxWidgets.

Qt went its own way and never went the same direction of MFC, as it was started way before MFC existed (AFAIK) and didn't work on Windows at the time, it was Linux only. Qt uses a thing called MOC (Meta Object Compiler). Don't think of Qt as its own language, everything is still done in C++. MOC was designed for reflection. To know what class it is, get the number of functions in the class and what not. Qt invented the signal and slot system you see in Boost and GTK. Qt is what you call event based GUI framework.

When a user clicks a button it'd send a message (signal) and whatever slot was connected to the signal would get that event and respond however to it. It is type safe, you don't have to worry about it messing up. It will just not call the invalid slot and will report the error letting you know.

Qt has a designer application which is just like wxWidgets in Dev-C++. But it allows you to create signals in it, wide range of widgets to use. You can even make a widget plugin and put your own widgets in to designer and drag them on to the form and see it in real time. You can see the code it generates (via MOC) and spits out 100% valid C++. wxWidgets doesn't do this. I cannot remember how it handles their design uis. When previewing the design you can change the look and all its styles to see how it would come out and make changes depending on how you see it best fit.

Qt has other applications also, a translator application for translating your applications. Qt-Creator, the IDE for Qt which supports code completion, Subversion, Git, CVS (I think), and others. It has a designer built in. So you can work in the IDE alone and what not.

Qt ships with a lot of modules in it. Ranging from SQL, network, XML, XSLT/XPath, to WebKit. Even COM support (which only runs on Windows). With QtActive, you can make Qt plugins for Internet Explorer if you want. There is also QtScript, which allows you to add scripting to your application via JavaScript if you would like to have it. It even has a debugger IDE for it.

Qt's code is very consistent in coding and design. It has its own build system called QMake. It works on Mac, Unix, Linux, and Windows. I haven't really used it except for testcases. I use CMake which is IMHO much better.

Configuring Qt is done on the command line similar to autotools configure. Most of the Qt modules can be disabled as fit.

Qt has a lot of books on it. And very updated unlike the wxWidgets book which was last written in a very old version of wxWidgets.

There is also another application that comes with Qt. It is called Qt Demo, which also lets you run all the examples and demo applications that demonstrates what Qt can do. There is, like, over 100 of them (estimating). It's fully documented and really easy to follow.

If you read comments from other people that complain about MOC and how bad it is, I wouldn't listen to them. Just think of MOC as this. If you use QtScript module, you can easily base data back and forward with no complexity unlike you would have to do if you was to a normal C++ application with Boost::Python for example. Take a look at KDE 4's Kross library. A lot of that work is done by what MOC can do.

Qt was made by Trolltech and then got sold to Nokia for more support on mobile phones, it even works in car embedded systems. I don't think wxWidgets can even do that, but I can be wrong. By Qt being bought by a heavy company like Nokia you know it will probably never die as the demand for Qt on phones and embedded are increasing. With wxWidgets it's made by developers (I have nothing against). It would die without warning. If Nokia went under it would be given control to KDE. But that will probably never happen.

Qt is professionally designed unlike wxWidgets. Nokia even opened up its repository to allow users to push features to it and help with it. So Qt is professionally and community driven.
Last edited on
Ok thanks a lot
Topic archived. No new replies allowed.