943,648 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 6292
  • C++ RSS
You are currently viewing page 1 of this multi-page discussion thread
Nov 6th, 2005
0

GUI with C++

Expand Post »
I wanted to explore and know about the GUI toolkits available to be used with C or C++.
I heard a bit about Qt, GTK, Mingw etc, and there's MFC too.
For the moment I am not quite sure which one to start with. Does a programmer need to know all of them? Which one do you pros use mostly in real life? Is one more important to know than the other?
Could anyone tell me about GUI in C++ in general and the toolkits/libraries available?
Similar Threads
Reputation Points: 113
Solved Threads: 3
Posting Whiz
Asif_NSU is offline Offline
353 posts
since Apr 2004
Nov 7th, 2005
0

Re: GUI with C++

depends on the operating system. QT is portable between both *nix and MS-Windows. The others are not portable. I'm not a *nix programmer, so I can only say that on MS-Windows the Visual Studio .NET 2003 (2005 coming out this month) are the best. But again, it is not portable to other operating systems. You might also check Borland products.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is online now Online
21,947 posts
since Aug 2005
Nov 7th, 2005
0

Re: GUI with C++

Quote originally posted by Asif_NSU ...
I wanted to explore and know about the GUI toolkits available to be used with C or C++.
I heard a bit about Qt, GTK, Mingw etc, and there's MFC too.
For the moment I am not quite sure which one to start with. Does a programmer need to know all of them? Which one do you pros use mostly in real life? Is one more important to know than the other?
Could anyone tell me about GUI in C++ in general and the toolkits/libraries available?
Sure. If you are just starting out with GUI's then stay away from MFC, far, far, far away from MFC. In fact, always stay far away from MFC, there are things out there that surpass it in every imaginable way. My main beef with MFC is its resource editor. It doesn't work half the time and it produces horrible code sprinkled with the most obnoxious comments. Then the whole MFC class library is completely unintuitive, and I swear it was written by monkeys.

Gtk is really good, Gtkmm (the C++ 'version' of Gtk) is excellent, and I use it a lot when developing on Linux. I haven't even tried to set up gtk on Windows, but I hear it is a lot of work.

ftp://ftp.gtk.org/pub/gtk/v2.8/win32/

FLTK (fulltick) is what I use for cross platform GUIs. It has its problems, but it is *extremely* easy to get running on any platform, and your code should be very portable. If I am doing stuff with OpenGL I use FLTK, there is a lot less work involved in getting things up and running with it than there are with Gtkmm. The two are actually really similar, and if you can learn one then you will be very quick to learn the other.

www.fltk.org

I hear Qt is pretty spiffy. I haven't tried it too much myself, so I can't give an opinion on it.

-Fredric
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
Daishi is offline Offline
80 posts
since Aug 2005
Nov 7th, 2005
0

Re: GUI with C++

Quote ...
My main beef with MFC is its resource editor
MFC (Microsoft Foundation Class) doesn't have such a thing as a resource editor. MFC is a library of functions, not a compiler or IDE.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is online now Online
21,947 posts
since Aug 2005
Nov 7th, 2005
0

Re: GUI with C++

Quote originally posted by Ancient Dragon ...
MFC (Microsoft Foundation Class) doesn't have such a thing as a resource editor. MFC is a library of functions, not a compiler or IDE.
Sorry, I was referring to developing MFC applications, and I haven't seen anyone do it without that resource editor that comes with MSVC++ 6.0.. Seriously, do you know of any good tutorial or something that you could post that doesn't use that resource editor at all? It is a piece of junk.

-Fredric
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
Daishi is offline Offline
80 posts
since Aug 2005
Nov 7th, 2005
0

Re: GUI with C++

what don't you like about it? just calling something "a piece of junk" is not very helpful. Do you have a better resource editor in mind? That's my opinion of QT too, but that doesn't mean it is no good -- it only shows my inexperience with the product.

Doesn't do bitmaps very well, but you can use other pait programs to create *.bmp files then import them into VC++ 6.0 project.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is online now Online
21,947 posts
since Aug 2005
Nov 7th, 2005
0

Re: GUI with C++

I sort of stumbled upon this:
http://www.geocities.com/SiliconVall...4/guitool.html

It says Qt is the best.
Could anyone tell me what is the relation between Qt and MinGW?
Reputation Points: 113
Solved Threads: 3
Posting Whiz
Asif_NSU is offline Offline
353 posts
since Apr 2004
Nov 8th, 2005
0

Re: GUI with C++

In my opinion, if you can sit down in a simple text editor, and without looking at any notes, write out the code for a simple application, then you are using the right libraries for the job. If you have to constantly look things up in a help menu or go to online tutorials, then you are using the wrong libraries for the job. If you can't write code that is self documenting, and understandable to someone who isn't familiar with the user interface that you are working with then that user interface is bad, and should not be used. In my experience this has been the doom of many projects that I have worked on with other people. They don't understand that 1000 lines of...

C++ Syntax (Toggle Plain Text)
  1. BEGIN_MESSAGE_MAP(CLayerTree, CTreeCtrl)
  2. //{{AFX_MSG_MAP(CLayerTree)
  3. ON_WM_CREATE()
  4. ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomdraw)
  5. ON_NOTIFY_REFLECT(TVN_BEGINDRAG, OnBegindrag)
  6. ON_NOTIFY_REFLECT(TVN_KEYDOWN, OnKeydown)
  7. //ON_WM_PAINT()
  8. ON_NOTIFY_REFLECT(TVN_ITEMEXPANDED, OnItemexpanded)
  9. //}}AFX_MSG_MAP
  10. END_MESSAGE_MAP()

...is going to completely ruin your day when a bug appears. Why? Because this code is not expected in the middle of a supposedly object oriented program, it is not intuitive what is going on here, or why you are doing it.

Going further, if you ever want to change the way a control looks, you wind up with code that looks something like this:

C++ Syntax (Toggle Plain Text)
  1. NMCUSTOMDRAW nmcd = *(LPNMCUSTOMDRAW)pNMHDR;
  2. if ( nmcd.dwDrawStage == CDDS_PREPAINT )
  3. {
  4. *pResult = CDRF_NOTIFYITEMDRAW | CDRF_NOTIFYPOSTPAINT;
  5. return;
  6. }

What was that? NMCUSTOMDRAW? LPNMCUSTOMDRAW? CDRF_NOTIFYITEMDRAW? I don't know what that means without a walk over to www.msdn.com, I've looked them up before but for some reason long lists of random capital letters don't stick in my head too well, and they shouldn't have to. Let's have a look at this superior product's documentation, shall we? Here is the opening to the NMCUSTOMDRAW documentation at msdn:

Quote ...
NMCUSTOMDRAW Structure

Contains information specific to an NM_CUSTOMDRAW notification message.

Syntax

typedef struct tagNMCUSTOMDRAWINFO {
NMHDR hdr;
DWORD dwDrawStage;
HDC hdc;
RECT rc;
DWORD_PTR dwItemSpec;
UINT uItemState;
LPARAM lItemlParam;
} NMCUSTOMDRAW, *LPNMCUSTOMDRAW;
Jeez, thanks Bill. That's some informative stuff you got there. I really enjoy wasting 99% of development time going through infinite loops of long random capital random letters.

-Fredric
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
Daishi is offline Offline
80 posts
since Aug 2005
Nov 8th, 2005
0

Re: GUI with C++

I have worked with MFC for sometime and then started Windows Programming with the pure C/C++ Code and the Win32 APIs. After that much of the things that were not clear in MFC became easier to understand.
All Win32 and MFC does is handle the Various Windows messages under some Event Handling Function. Once you get to know these events, the names given to the handler functions become clear, and you will see that the names are not that random as it initially seems.

For Example - The Prefix NM will denote Notification Message.
WM = Window Message
TVN_KEYDOWN is a specific window message sent from the TreeView ( Hence the Prefix TV ) and since this is of the form of a WM_NOTIFY Message, the Prefix is TVN. A Programmer who has spent some time in Win32 will know that this notifies when a User presses a key when the TreeView Control has input focus.
Similary if you look up the documentation for NM_CUSTOMDRAW you will understand what are the parameters that are passed in he NMCUSTOMDRAW structure. All depends on what you are conversant with.

Yeah in a way I agree with Daishi in that MFC is not that well structured. But this is not due to its resource editor, but the way it generates the Code. I however think that this can be cleared up to some extent if you did some pure Win32 API Programming.

I dont see why it is bad to refer documentation all the time. While we can get a rough idea of the Events that are to be used just by looking at them, with so many APIs in the Win32 Library and the MFC Libraries, I dont see how can one memorize all of them with all the parameters and such. And again I think ( IMHO )that the Win32 API is very well documented. Microsoft products are not that bad as it is said to be. :cheesy: But these views are very much dependent on the amount of practice you have on the specific library so no hard and fast rule as such.
Moderator
Reputation Points: 572
Solved Threads: 115
Mentally Challenged Mod.
WolfPack is offline Offline
1,559 posts
since Jun 2005
Nov 8th, 2005
0

Re: GUI with C++

Quote originally posted by Daishi ...
In my opinion, if you can sit down in a simple text editor, and without looking at any notes, write out the code for a simple application, then you are using the right libraries for the job. If you have to constantly look things up in a help menu or go to online tutorials, then you are using the wrong libraries for the job.
Bullpucky! All you want to do then is write console applications. There is NO GUI operating system or set of libraries that are that easy to use. If you think MFC and MS-Windows is difficult, then switch to *nix and use X11 and Motif. or program for MAC os. Or if you want to use a simple text editor such as Notepad.exe then you should be writing HTML code, not C or C++.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is online now Online
21,947 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Can anybody tell what's wrong with this code?
Next Thread in C++ Forum Timeline: Help with Array





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC