tags:

views:

1369

answers:

14

Guys I study C++ for a second year. Till now I was doing only console app but I think it's a time to start programming in Windows. There are few alternatives and Qt is one of them but I'm also drawn towards pure Windows API - for more power of course. What would you suggest?

+6  A: 

Anything as long as it is not MFC :)

Justin Ethier
Oh, I dunno.... MFC vs Win32... which is eviler?
Randolpho
I've heard that MFC sucks? Why people don't like it?
smallB
I've done MFC and I've done straight Win32. MFC is far better.
David Thornley
@David: I've never used MFC... is it really all it's cracked up to be?
George Edison
@George: I don't actually know what it's cracked up to be. It's certainly usable, and much better than Win32, although very definitely not the best GUI framework I've ever used. It's basically a lot of widgets with magic macros to paste everything together, with an inflexible resource file format.
David Thornley
+25  A: 

I depends on what you want to build.

Qt is a very clean and powerful API. It has a very nice object model for both GUI and almost everything else you can think of. It's also very extensible.

The "pure" Windows API, when I saw it, was mostly a lot of Visual Studio created macro's and such, not nice to read at all. It may be different now, of course. But I feel that if the C++ API were that clean no-one would have bothered creating C#.

So I would suggest you define a smallish GUI project with all the facets you want to be using (DB? XML?) and write that in both "pure" Windows and Qt, and see what you like most.

I think you'll find that, as always, power comes at a cost. And it's up to you to decide whether that cost is worth it.

extraneon
The pure Windows API has no VS created macros, as quite a bit of it predates VS, and all of it can be used without using VS. Perhaps you are thinking of MFC?
anon
+1. One thing though: When you say _"C++ API"_, it should be said that Windows' native API is a better fit to C than C++. MFC can be seen as an object-oriented wrapper around the API with C++ in mind.
stakx
+3  A: 

Qt is a great platform to start on, it gets your feet in the door for intelligent ui programming and has lots of great power tools (like QPointer classes, etc...) to give you a base API for programming efficiently in C++

It's not the only one out there ofcourse, but it's a good framework and your software will be cross-platform out of the box as long as you dont do OS specific stuff on the side.

Aren
+5  A: 

Can't really compare insightfully on the pure Windows API but one obvious difference is that you're effectively bound to one platform with the Windows API.

Qt is cross-platform for free (and is very mature, fast, well documented, has good support tools, ...).

ChristopheD
-1 You are not bound to Windows just because you use the Windows API. A compatibility layer, like WINE, will let you run the apps on linux/unix.
George Edison
Getting Windows stuff to work via WINE can't really be seen as truly cross-platform in my opinion...
ChristopheD
Yes, it can. You can even use darWINE to get them running on a Mac.
George Edison
My definition of cross-platform: does not need an emulation layer like wine, uses native widgets wherever used.
ChristopheD
+13  A: 

I've used Qt 4 for a couple of smaller projects and I was thoroughly impressed with the clarity, consistency, and simplicity of the APIs. After a couple of hours of reading the documentation I was able to start writing GUI applications which were more robust, higher performing, and easier to maintain than comparable Java/Swing programs.

If you're interesting in gaining some breadth of experience then I'd recommend picking a small project and trying to implement it in a few APIs, see what suits you.

maerics
+6  A: 

Qt is terrific if you want something to be cross-platform. It is very robust and extremely well documented. It also has a decent IDE to help you rapidly develop GUIs. I'd say you should at least take a look at it if there is a possibility you'll ever want to use the code anywhere but windows. I've used Qt a bit in the past and it is an extremely good package.

Really, you should probably look at both and weigh your options. Qt is cross platform, Windows API is not. Windows API has Visual Studio and can develop GUI's extremely quickly. Qt has it's own IDE that is good, but not as good as Visual Studio for rapid prototyping. With Qt, you have to make sure the people using your software already have Qt or statically bind the runtimes which increases the size of the executable by a lot. Windows API you don't have to do that, but again, it only runs on Windows.

Decide what you want to use it for, then choose what to look at. Both are very good to learn.

Brent Parker
A: 

I strongly suggest going the Windows API route.

This is what I did. I learned the ins-and-outs of the Windows API, and later learned Qt.

The advantages of this are:

  • Practical experience with an API
  • Appreciation for "the hard way"
  • A more in-depth understanding of interacting with hardware

Note: Qt does not use native controls of the host OS, so there will be inconsistencies between a Qt app and a Windows API one.

George Edison
I think I'll take this route.
smallB
Great! All the best to you.
George Edison
Note: recent Qt versions (4.5+) do use native controls of the host OS.
ChristopheD
@ChristopheD: link please?
George Edison
This stackoverflow answer for example: http://stackoverflow.com/questions/676601/qt-gui-internals-widget-painting/677998#677998 (some other Qt and Wikipedia links further down the page).
ChristopheD
@ChristopheD: according to the answers in that question `Recent versions of Qt use the native APIs of the different platforms to draw the Qt controls`. Having the native API draw the controls and having the native API *create* the controls is different. They may look the same, but the functionality will differ.
George Edison
@George Edison: that seems to be the case, yes (point taken).
ChristopheD
also what do you mean look like a winapi app? Office, VS2010, WPF, MFc, Silverlight> There isn't a Windows native look anymore
Martin Beckett
@Martin: There is: it's managed by `uxtheme.dll`.
George Edison
-1 I find this answer wrong for many reasons. What's the point of mastering programmer-unfriendly API when there are many better alternatives? Appreciation for "the hard way" is just ridiculous, you might as well recommend source version control through zipping and manual comparison of files (cause SVN, git and merging tools are for wusses, right?). And while I agree that some level of understanding *how* things work is necessary, I think that understanding how WinAPI works is not necessary for someone that just starts GUI programming.
chalup
But that's what I did.
George Edison
I disagree with all of your reasons: first of all, you gain "practical experience with an API" by using any API. Almost no one is using WinAPI any more because it's an ancient C API with many warts and compatibility hacks.Second of all, gaining appreciation for the "hard-way" is a waste of time. As an example, it took me all of an hour of studying Symbian C++ to judge it as terrible and appreciate Qt as incomparably better for Symbian development.Third and last, WinAPI is used to program an OS, not for interacting with hardware.
rpg
To add to what chalup and rpg said, even microsoft have migrated away formt he win32 api to .NET. Having used win32, gtk, fox and fltk, I personally think Qt is the best route these days (and your app will be compilable on linux and mac os x), unless you are using a .NET language, in which case, use winforms.Telling someone to use an obsolete, error prone api like win32 is just bad advice IMHO.
Dan
The Windows API is not any more or less error prone than anything else. And a lot of the underlying code for .net was written using the.... Windows API!
George Edison
@George: And machine language is at the bottom of any language, but that doesn't mean I recommend learning x86 before learning C++. Lower-level stuff is generally more error-prone, because you can make mistakes on more levels. It's generally uglier and harder to learn, with more special cases.
David Thornley
+10  A: 

Qt is actually more powerful than pure Win32 API. Part of the reason is that Qt uses its own widgets (it just draws them in the same way native widgets are drawn), which lets it implement additional features which stock Win32 widgets don't have.

Pavel Minaev
+4  A: 

Design your applications with a division of responsibilities, and keep the GUI separate from the rest of the code. Doing both Windows and Qt at the same time will give you a good example of how this works out in practice.

Mark Ransom
A: 

I guess you already decided to go with win32 API. This is a mistake IMHO. As far as GUI API's go, win32 is ancient, convoluted, and really won't do much toward helping you learn modern UI development. May as well write in X Intrinsics.

Of course, I wouldn't go with Qt either. Qt extends the language unnecessarily. There are several other options that do not do this. wxWidgets, FoX, and gtk-- to name three. Out of those I would recommend GTK-- simply because it uses a nicer interface for events in my opinion.

Noah Roberts
I'd go with wxWidgets - GTK is a pain on Windows :)
George Edison
+2  A: 

I've used both pure win32 API (building my own event loop and handling messages) and Qt. I'd say win32 API is handy if you need really low-level stuff but it's a real pain to construct anything that's more than a few buttons and controls. It has it's uses, for instance when you need to prepare a window to be used for Direct3D output or a single notification area icon, but doing more is complex and requires quite a lot organisation from the programmer part. Not to mistake pure win32 API with MFC though.

Qt on the other hand is a breeze to create UIs and whatnot. It has a solid, well documented and quite intuitive class library. Simple and trivial tasks are actually simple and trivial, but it is easy to miss the internal details which might get back at you later. Or might not. I'd recommend Qt as a native GUI framework any day.

And it gets us to the point where win32 API is just an API and Qt is a framework. If you're in academia, it means you want to learn how stuff work. And win32 API will let you do just that - learn intricacies of GUI programming, most likely the hard way. Qt abstracts quite a lot of the internals away.

Therefore I suggest giving Win32 API a shot so you have a an idea how things really work at the heart of your GUI application and maybe move on to frameworks (I personally recommend Qt) if you need to build something more complex.

frgtn
+2  A: 
Norman Ramsey
+2  A: 

Yes, you should. Qt 4 is the most flexible and most powerful C++ GUI toolkit I ever encountered, and it is also very clean. IT is also cross-platform and isn't tied to single platform. Download Qt 4, and run qtdemo. It will show all available technologies. With all due respect to other toolkits, I haven't seen anything even remotely similar implemented in pure winApi, GTK, FoX, or wxWidgets. I doubt you'll have any questions after seeing that.

SigTerm
+1  A: 

Well, it's an yet another suggestion - Yes, you should learn Qt. My point is - it's clean, well documented and can be ported across multiple platforms. Since you have learnt C++ for the past 2 years, moving to Qt will be quite easy. I mean it. And also Hey LGPL is available. Just download it and learn. IMO learning Qt is quite easy and enjoyable too..

liaK