About graphical user interfaces in c++

Hello!
I need to know ,that how to create a graphical user interface in c++.
can somebody please tell me the way to do it, or if you have a code can
somebody please send it to the forum.

Thanks.
Hlakna,

This is a good place to start: http://winapi.foosyerdoos.org.uk/info/user_cntrls.php. It has some good code examples as well as additional reference for GUI interfaces.

phyz
You need to use a GUI Toolkit. There are many available.

QT, GTK++, WxWidgets, FLTK, FOX.

I use wxWidgets - http://www.wxwindows.org/
Remember however that not everything is Windows based.
Try some multi-platform libraries (such as SDL, openGL) so that in case you switch OS's, you won't have any problems recompiling or having to learn a new library.
SDL and OpenGL are unstructured interfaces, better suited to game and graphics programming.

GUI toolkits are often highly structured, more suited to your standard "windows" application.

In all cases, each library has significant differences and you must familiarize yourself with each one.
Remember however that not everything is Windows based.
Try some multi-platform libraries (such as SDL, openGL) so that in case you switch OS's, you won't have any problems recompiling or having to learn a new library.


Err...
QT, GTK, WxWidgets are all Multi-Platform.
I am currently trying to get to used to Qt, it looks kind of useable. Someone on IRC said, though, that they were constantly working against it, due to the poor code it generates. Is that true (of course machine-generated code holds lot of space for optimisation, I should think, but does it geenrate code which is grossly inefficient, is my question), or is it rather a matter of taste?

Edit: Also, none of the above links work for me. The first gives me a 404 error, the latter an empty directory.

Edit 2: Thanks Aakanaar, not looking at the URL was my mistake :(
Last edited on
Dunno about the empty index (i'm getting that too) but for the first one
Click the link, get your 404 error, go up to address and erase the period at the end of the addres

Or right click and copy link, paste into address bar and erase the period at the end.

edit: Ok, found problem with second link. He meant wxwidgets.org not wxwindows.org

So use http://www.wxwidgets.org/

Edit 2: Ok.. So I like WxWidgets. It's free, open source, multi-platform, and from what I see, it's thin and doesn't have a lot of overhead. Anything to make creating and using a GUI is good for me.

On the other hand, i've always been warned to stay away from stuff that auto-generates code for you, as they are never optimised for speed, and have a lot of overhead (includes entire headers even if you only need one function). At least those warnings always came with why we should never use MFC.. so i've never used MFC.

Is this different? Is this better than MFC? Is the tradeoff of speed and size worth the savings of my sanity from the gui code problem? Will Batman save Commisioner Gordon from the Joker's evil and mischevious trap?
Last edited on
Qt is a very powerful, very complete package. It isn't just a GUI framework, it is an "application framework" --meaning it includes a lot of stuff besides just what you need to display pretty windows. I would be wary about listening to people on IRC complain about poor code generation when using a library --compilers generate code, not libraries. Perhaps he ought to get a better compiler? A good optimizing compiler will get rid of unused stuff (or "dead code").

The main thing about Qt is that it is a proprietary commercial product. Trolltech lets people use it for free to develop free stuff, but you must have a commercial license to use or develop with it commercially, and you can never mix the two.

GTK, WxWidgets, FLTK, and FOX are all much smaller libraries, designed mainly as GUI toolkits. They are all very good and popular. I suggest you look through their docs and examples and decide which you like best and/or which best suits your needs.

The Batman always wins. :-)
hello..
i am new here..
I'm just browsing the internet to find tutorials for c++,
and i found this site..

i want to try to ask how can i insert image to my some c++ program?

sorry,,, cause I'm not good in English

hope some body read my post and help me.

thank you...
Sorry bout the link, it used to be called wxWindows :)

WxWidgets is similar to QT in that it also includes other components (networking, databases etc) that a normal GUI Toolkit doesn't include.

As for code generation, are they taking about dialog editors like the one provided by wxWidgets? I have always coded the UI myself manually (similar to Java's SWING/AWT)
well, I mentioned code generation, i think cause someone above said it. I think they mean that the code in the libraries arn't optimized.

Generally speaking, almost every win32 tutorial I've seen online have one main re-occuring statement, and that is to avoid MFC. Mainly cause the functions in MFC were generalized and not neccessarily specific to what you needed. As a result, they were bloated, and not optimised for speed, etc.

WxWidgets looks interesting (been reading the documentation section trying to decide if I should download) but I wonder if it's just another MFC in sheeps clothing.

It really comes down, i suppose, to which is more important to you as a programmer. The ease (well, easier anyway) of a library that is setup to handle Windows GUI (or cross platform GUI as in this case) or the headache of doing the GUI code yourself using windows.h. (which isn't cross platform)

I'll be reading that first link thoroughly, as in some cases, it may be better to just do it "The Hard Way".

Edit::
But while i'm on the topic.. I also know that a lot of windows programs can be done using dialogs which can be built in a resource file. I'm using DevC++ and it has no resource editor capable of generating dialogs.. so I'm kina looking for something that'll help me do that, as well as figgure out how to use those effectively.
Last edited on
Another question, concerning Qt:

If I were to use Qt under OSX to create a GUI for a program, how portable would that be, specifically to Windows XP? I'm guessing not very, but I'd be very happy to learn that I am wrong, since it would not require me to learn how to write GUI code for Win in C++ (currently reading the relisoft tutorials).
closed account (z05DSL3A)
If I were to use Qt under OSX to create a GUI for a program, how portable would that be, specifically to Windows XP?

See: http://trolltech.com/products/qt/

NB: Before you commit to learning QT, make sure you understand the licensing of it.
Last edited on
I see. That's very good news, really.

As for the licensing, we already have a commercial Qt license, so that should not be a problem.
Wow. Nice! By all means then, use Qt. It is one of the nicest systems I know of. (That license is just about worth its weight in gold ;-)
Last edited on
Topic archived. No new replies allowed.