Hi fellows,

My question is: Is It possible to work with GUI(Graphical User Interface) in C++?

Or Is it not the ideal computer language for this?

Thanks

Recommended Answers

All 5 Replies

Yes, it is possible. And Yes, c++ is not the best language for it any more -- vb.net and C# are easier for MS-Windows. If you want cross-platform, then QT is a better solution. There are many ways to write GUI applications, some platform dependent and some are not.

Is It possible to work with GUI(Graphical User Interface) in C++?

Certainly. It's all pretty much dead on the "Microsoft" side of things (Win32 and MFC are pretty much deprecated now, and all alternatives are .NET, which isn't very C++-friendly). But that does not really matter (who would use Microsoft products in C++ anyways?). I would recommend Qt for all your GUI needs. It is very easy and portable, and overall pretty well designed (albeit a bit old-fashion). Other alternatives, like VCL or WxWidget, are, for the most part, not very attractive compared to Qt.

Or Is it not the ideal computer language for this?

Not exactly ideal. GUI programming is one of those areas where object-oriented programming is very appropriate (a lot of reliance on run-time mechanisms), and where a garbage collector does make life easier. Doing object-oriented programming in C++ is perfectly fine, although it is a quite small subset of the C++ language as a whole (so, to me, it feels like driving a sports car and only using the first gear). And I have not seen a GUI library in C++ that includes a garbage collector, and that could make some things easier.

Certainly, languages that are "pure" OOP and garbage-collected (C# / Java) are more ideal for GUI programming. Well, those languages were designed explicitely for that purpose, so it would look pretty terrible if they were not even good at that.

That said, doing GUIs in C++ is still very easy (if you're comfortable with C++, of course), and also faster and lighter-weight than the .NET / JVM alternatives. If you need to do GUIs just as small front-ends to lots of C++ code, then I would stick with only C++ for the GUI too, just to avoid the trouble of interfacing languages and all that. But if your primary task is all about the GUI, then you could consider going with C#/Java.

And there is also another alternative in the middle, which is quite popular, which is to use Python as the GUI language. Python is good for GUIs because it has good bindings to C++ GUI libraries like Qt (i.e., you can have Python programs that construct GUIs through bindings with Qt (which is C++)). And it is also very easy to create Python bindings for your own C++ code (e.g., Boost.Python), meaning that it makes the whole process very easy, and you don't have to suffer the penalty of using clunky non-portable mammoths like .NET / JVM. This C / C++ / Python stack of languages has been gaining lots of popularity for that reason.

That said, doing GUIs in C++ is still very easy (if you're comfortable with C++, of course)

Maybe for people like you, but for us mere mortals it can be very undaunting and take years to write/test/debug significant applications in pure c++ and win32 api (assuming MS-Windows os). Yes, there are a few libraries such as wxWidgets and QT that make it a little easier, but still is not "easy".

Point taken, I guess you could say I don't judge difficulty like most.

But still, GUI programming in general (regardless of language) is mostly a matter of doing a lot of fairly trivial coding (coding event handlers, drag-and-drop designing the interface, and writing simple front-end code). So, in my perspective, GUI programming can either be extremely easy, up to just easy, and in C++, it's in between, at "very easy". But I also don't really have huge experience with GUIs, I never wrote GUIs larger than 30-40 kLOCs.

I first started doing GUIs about 15 years ago, with Delphi (with VCL (Visual Component Library)), which is well-known (in its day) for being one of the best GUI toolsets out there and for pioneering RAD (Rapid Application Development). To me, this was indeed a wonderfully easy language + GUI library combination, pretty much as easy as can be. Then, I moved to the C++ port of the VCL (in C++Builder), and it was nearly as easy to use as the native Delphi version. Now, I use Qt for most GUI things I do (which is not much in comparison to the "real coding" that I do). And, in my opinion, Qt in C++ is still very easy, certainly not nearly as good as the VCL, but the portability (across OS and across development environments) and the fact that it is still "alive" and actively developed make it the best choice.

take years to write/test/debug significant applications in pure c++ and win32 api

I can understand that. Writing anything significant with the bare Win32 API must be a daunting task.

For my assignments this year we were required to implement GUI. At that time I only knew C++. Things got a little too difficult for me creating GUI in C++. I tried downloading Qt but my internet connection is so bad that it was taking forever to download. So I decided to just learn Java and try implementing GUI in that language. I watched tutorials and it was much much easier.

However I saw some tutorials on Qt GUI's and I liked what I saw also seemed simple.

All in all, C++ GUI - very difficult(for me), Java GUI - fantastic and easy enough.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.