# How to build GUI in c++?



## clmlbx (Dec 19, 2011)

Guys I have self learned c++.now I wish to make GUI for some programmes that I have written in it.. So guys pls tell me where to start... pls give step-by-step as I have no previous knowledge in it.. 

I learned c++ online and few good videos. I have never read any book. All tuts even books, at least what I have seen start and end in 'CLI' no one has topics for GUI..


----------



## nims11 (Dec 19, 2011)

i use Qt for making GUI with C++. it is very powerful and well-documented. But you need to have your OOP concepts clear in order to get comfortable with Qt.


----------



## krishnandu.sarkar (Dec 19, 2011)

Yup..!! I've used Qt too..!! The best thing is it's Documentation.

But as already said by nims11, you need to have a good base on C++, which I didn't have.

So now as I know the basics already, I'm planning to learn C and C++ again now in advanced mode.


----------



## $$Lionking$$ (Dec 20, 2011)

clmlbx - Win32 API...  try D.J. Delorie (djgpp) or what I personally use -> Bloodshed(needs manual updation). 

Also visit developer.amd.com -> try the nice profiler(AMD Code Analyst) from AMD. It will really help you optimize a lot.


----------



## sakumar79 (Dec 20, 2011)

VC++ is very easy to use and creating GUI using it is simple. It is available in Express Edition as free of cost. The only downside is that it will work only in Windows...

Arun


----------



## clmlbx (Dec 20, 2011)

Well it seems I have to try all three ..and I will then decide which suits/easy is for me..but no one gave me step by step guide to start.. pls tell me where to start.


----------



## krishnandu.sarkar (Dec 20, 2011)

Lionking and nims11 have suggested two diff. things.

May be that's why you are confused.

If you are looking for frameworks to develop GUI Apps, say like Visual Studio, you are probably looking for what nims11 have suggested, i.e. Qt.

And if you are looking for learning Graphics Programming (Core Level), like Drawing Windows, Buttons yourself by probing the Graphics Driver, then you are looking for what LionKing have suggested.

You can also use VC++ to develop GUI Apps like sakumar suggested, it's somewhat like developing GUI Apps using VB.NET / C# in Visual Studio. (May be, I'm not sure about this )

So, both are diff things, and you choose depending upon your requirement.

If you just want to simply develop GUI Apps without much headache then Qt / VC++ is the thing you are looking for.

Or if you are in to graphics programming then go for what Lionking has suggested, you can also do the same thing in VC++. I guess that's what we call VC++ Win32.


----------



## clmlbx (Dec 20, 2011)

well for now I should start with framework rather going for core level graphics programming.. so will start with VC++ as it must be having good support(many user will be using it).. so I will get good start.. later may also try at Qt as nims11 said it has good documentation..

Thanks guys.


----------



## Liverpool_fan (Dec 20, 2011)

The Qt4 tutorial


----------



## $$Lionking$$ (Dec 21, 2011)

krishnandu.sarkar said:


> Lionking and nims11 have suggested two diff. things.
> 
> May be that's why you are confused.
> 
> ...



I havent used MS VC++ a lot but from what I understand, VC++ should be very different from .NET framework or any other language in the framework like VB.NET C#.NET haskell etc.. 
for 1 thing it is the only language available independent of the Visual Studio.

Developing apps in VC++ is nothing like developing apps in VB.NET or C#.NET. 
VC++ is not a RAD language. u want to draw a window? u have to write code for it! While C#.NET & VB.NET are more like paint brush with dimension's.

Comparing TrollTech Qt to VC++ - not right bro.. both use different API's!

I did not suggest graphics programming at all??!?!?! Although with my approach you can go for DX10/DX11 programming too but that's a totally different thing, and beyond the scope of discussion for this forum.... 

yes I did suggest the Win32 API or Windows 32bit API. 
On Windows API are Microsoft Foundation Classes(MFC) based using which you write your code in VC++.

@OP - Going for MFC without learning API is like trying to understand words when u dont know ABCD... Not possible. Even if you succeed to some level, you will have problem to debug.

You should go for Gtk or Win32 API. Also you should start by downloading DJ Delories or Bloodshed.... I did guide you from where to start... once you use them a lil bit ull know what ure dealing with.

But to be more honest with you, you will find it difficult be able to do Gtk or Win32 API. 
So in the end you should go ahead with JAVA or VB.NET. (Sorry C# dont make no sense to me!!)

Enjoy!


----------



## krishnandu.sarkar (Dec 21, 2011)

@Lionking Yes you are right, that's my mistake. 

VC++ is what I was referring to for writing code, and VB.NET / C#.NET is different thing.

Thanks for correcting me. 

I forgot that I learned Win 32 API in VC++ back in college days, which we actually used to call Graphics Programming.


----------



## abhijangda (Dec 21, 2011)

There are many GUI toolkits for C++, the major ones are gtkmm, wxWidgets and Qt. Qt is the best one, I think, but others are very good too. But you should have a firm base of OOP in C++.


----------



## sakumar79 (Dec 21, 2011)

VC++ also now works with .NET Framework AFAIK - It is included in Visual Studio... And regarding help, there is a lot of online resourses for VC++ definitely.

Arun


----------



## krishnandu.sarkar (Dec 21, 2011)

Unless one doesn't wants to go in Core level Graphics Programming like in Games, it's not needed to go with Win32 API using C++.

Because everyone will try to avoid those hassles of drawing Windows and all.

If @OP is looking for GUI based App. Development, Qt is recommended.

@OP, I did a mistake while suggesting. I'm really sorry about that.

If you are looking for GUI App. Development without the headaches of Drawing Windows and all like in VB / VB.NET / C#, Qt is the thing you are looking for. Take a look at the link which @LFC_Fan posted above. Other than Qt there are Gtk, wxWidgets etc. But Qt is much better and recommended over others. Reasons already posted in the very beginning by nims11.

Otherwise you can go with Win32 API with VC++ if you like to draw everything on your own, it's core level graphics programming.


----------



## sakumar79 (Dec 22, 2011)

^^     I dont know where you got the idea that for VC++ you draw everything on your own... VC++ is just like VB in GUI - you can drag and drop labels, textboxes, etc into a form and arrange them, double click to open code writing, etc... Another advantage (I dont know about Qt, so I dont know if this feature is there or not), but there is on-the-fly error report for pointing out syntax errors, nondeclaration of variables, etc..

Arun


----------



## krishnandu.sarkar (Dec 22, 2011)

Well actually I learnt graphics programming in VC++ using Win32 API. I don't know whether it's possible to do it same like in VB.

Sorry for the mistake.

Sent from my LG-P500 using Tapatalk


----------



## clmlbx (Dec 22, 2011)

@ Liverpool_fan thank you for that QT tutorial ..

thank you guys foll all your input.. I know now their are two ways of creating GUI either by core level graphics programming or by forms.. I will choose forms for now as I am not at all interested in going for core level graphics programming.. I want easy and quick way to create GUI and apparently forms is the quickest way to do it..

Programming is not at all related to my field or work (Graphics Designing). It is just I love writing codes,I love using logic and it's just my hobby.. So forms it is but I will try QT soon and  hope that is as easy as it sounds.. I got my self fully loaded with visual c++ express edition and Book (Ivor Horton's Beginning Visual C++ 2010).. but It is going to be very slow process  as I can get to it in only once a week or so. Hopefully will start in few Days..


----------



## abhijangda (Dec 22, 2011)

ZetCode, tutorials for programmers has one tutorial for beginners. 

Also, I would recommend following books
C++ GUI Programming with Qt 
The art of building Qt applications

Although, I haven't read anyone, but on googling I found good reviews. Also, I have been doing gtkmm and it is simple as compared to Qt. At first stage I would recommend gtkmm and then go for Qt. Actually, Qt came at the time when standard ANSI/ISO C++ was not defined, hence Qt has so many of its own features which C++ has after its standardization. That's why, you will use qmake to compile and create projects and makefiles. While gtkmm and wxWidgets use compilers like g++. 
If you start with gtkmm then there is a very good book available 
Programming with gtkmm 2 and Programming with gtkmm 3.

Good Luck!!


----------



## $$Lionking$$ (Dec 22, 2011)

sakumar79 said:


> ^^     I dont know where you got the idea that for VC++ you draw everything on your own... VC++ is just like VB in GUI - you can drag and drop labels, textboxes, etc into a form and arrange them, double click to open code writing, etc... Another advantage (I dont know about Qt, so I dont know if this feature is there or not), but there is on-the-fly error report for pointing out syntax errors, nondeclaration of variables, etc..
> 
> Arun



not right bro!!!


----------



## Liverpool_fan (Dec 23, 2011)

The thread has run its course. The OP can create a thread on help on the specific GUI toolkit if s/he desires. 

EDIT: Thread reopened as per request. Please keep the discussion healthy and check the accuracy of your posts before posting. Thanks.


----------



## umeshtangnu (Dec 23, 2011)

$$Lionking$$ said:


> not right bro!!!


he is right  Visual C++ or its more technical term MFC supports gui building with minimal need for writing code for GUI 
what you are talking about is Visual C(win32sdk),which uses C to call Win32 functions .
On Win Platform best way to code the GUI is MFC .for multiplatform you can use QT,WxWindows,GTK,JUCE, etc etc .Its upto u which GUI library you want to use but i will recommend that as you are a newbie is this field its better to go with low level API's first so as you what that boiler plate code is doing .
On windows you can refer Petzold and nothing Petzold is enough for everyone .
Once you are comfortable move to a GUI library   

But


----------



## $$Lionking$$ (Dec 23, 2011)

umeshtangnu said:


> he is right  Visual C++ or its more technical term MFC supports gui building with minimal need for writing code for GUI
> what you are talking about is Visual C(win32sdk),which uses C to call Win32 functions.



not right bro....

Visual C++ or its more technical term MFC - as far as my understanding goes both are very different... MS VC++ is not MFC.... VC++ is an IDE. MFC is a liabrary.

VC++ supports gui building with minimal need for writing code for GUI - this is relative. I meant it does not support drag and drop like mechanism of VB.NET. anything is much less code vs Win API..

what you are talking about is Visual C(win32sdk) - Visual C? doesnt ring any bells for me.. (VC++ does.. ) 
Win32SDK - actually... i was talking about Windows 32 bit API.. SDK or no SDK... 



> On Win Platform best way to code the GUI is MFC. for multiplatform you can use QT,WxWindows,GTK,JUCE, etc etc. Its upto u which GUI library you want to use but i will recommend that as you are a noob is this field its better to go with low level API's first so as you what that boiler plate code is doing.
> 
> On windows you can refer Petzold and nothing Petzold is enough for everyone. Once you are comfortable move to a GUI library.



On Win Platform best way to code the GUI is MFC - MFC adds a lot of overhead and is not ideal as far as i know... although MFC can help u work faster so its a a tradeoff ill say rather than calling MFC the best way.... 

for multiplatform you can use QT,WxWindows,GTK,JUCE, etc etc - Gtk is something as powerful as Win32 API - apart from multi-platform, its pretty easy vs Win32 API. So thats always a good way to go.... 

i will recommend that as you are a noob is this field its better to go with low level API's first so as you know what that boiler plate code is doing - Hey 1stly - Win API is serious business, not for noobs. 2nd API code is faster than MFC code anyday. 3rd - I dont think MFC or API are the solution here...

OP mentioned earlier that he's a graphic designer, and a hobbyist programmer, thats exactly whom VB.NET is for... He should go with VB.NET no issues about handles, winprocs.. etc.. 

drag & drop gui with easy to implement logic!!!  

I hope OP goes for


----------



## umeshtangnu (Dec 23, 2011)

> Visual C++ or its more technical term MFC - as far as my understanding goes both are very different... MS VC++ is not MFC.... VC++ is an IDE. MFC is a liabrary.


actually the terms are interchangeable . i means both ide and the MFC  .
eg 


> Microsoft Visual C++ 6.0 is the latest version of the industry-standard programming language for professionals. And "Programming Visual C++, Fifth Edition", is the newest edition of the book that's become the industry-standard text. Newly expanded and updated,


quoted from here



> VC++ supports gui building with minimal need for writing code for GUI - this is relative. I meant it does not support drag and drop like mechanism of VB.NET. anything is much less code vs Win API..


check the attachment for the drag n drop sample



> what you are talking about is Visual C(win32sdk) - Visual C? doesnt ring any bells for me.. (VC++ does.. )
> Win32SDK - actually... i was talking about Windows 32 bit API.. SDK or no SDK...


every API is wrapper over win32sdk on windows platform ,it is the most basic way to build any application on windows 




> On Win Platform best way to code the GUI is MFC - MFC adds a lot of overhead and is not ideal as far as i know... although MFC can help u work faster so its a a tradeoff ill say rather than calling MFC the best way....


ya the overhead would have been problem if we still had AMD K2-6 procs.
and same overheads are found with other GUI libs.


> i will recommend that as you are a noob is this field its better to go with low level API's first so as you know what that boiler plate code is doing - Hey 1stly - Win API is serious business, not for noobs.


its looks like that believe me it is for more easy than it looks


> 2nd API code is faster than MFC code anyday.


also faster than everything else.


> 3rd - I dont think MFC or API are the solution here...
> OP mentioned earlier that he's a graphic designer, and a hobbyist programmer, thats exactly whom VB.NET is for... He should go with VB.NET no issues about handles, winprocs.. etc..
> 
> drag & drop gui with easy to implement logic!!!
> ...


then C# will be better as the syntax is similar to C++ .


----------



## Liverpool_fan (Dec 23, 2011)

I would like to put a reminder that personal slurs and patronising tone of posting is NOT allowed in this forum. Kindly recheck and edit out your posts yourself, you have 8 hours. Would be beneficial for your forum health, otherwise someone is going to get hurt. Bit sick editing out myself tbh.


----------



## $$Lionking$$ (Dec 23, 2011)

> Microsoft Visual C++ 6.0 is the latest version of the industry-standard programming language for professionals. And "Programming Visual C++, Fifth Edition", is the newest edition of the book that's become the industry-standard text. Newly expanded and updated



What are u trying to tell here?? Its from 98 that time VS6(Hence VC++ 6.0) was probably out, there's 1 reference to that and there's a reference to a book named "programming for VC++" nowhere is mentioned that terms are interchangable.... 

although f u want to argue about an IDE's name being used in place of a libraries name.... ill be more than happy to post you some links from wiki.... 



> every API is wrapper over win32sdk on windows platform ,it is the most basic way to build any application on windows



1. No API is a wrapper over win32sdk because its a win32sdk is a SOFTWARE DEVELOPMENT KIT. and wrapping API over an sdk dont make sense.
2. every API is wrapper over win32API on windows platform ,it is the most basic way to build any application on windows. but yeah - that's not true in entirity, either!!! 



> ya the overhead would have been problem if we still had AMD K2-6 procs.
> and same overheads are found with other GUI libs.


yeah right... we shud also throw away all the algorithms that make our softwares more efficient... its not like were running K6-2 right?  - wrong attitude bro!!!!!!!!!!!!!



> its looks like that believe me it is for more easy than it looks


There's a looooooooooot of things u need to rmr all at the same time!!!! Codes are really really long dude, how is that easy in any way... 

A year back I made a calculator its a 1000 page code!!!! Ok, metphorically spkng, but u get my point?!



> then C# will be better as the syntax is similar to C++.


Java is better than C#.NET. Dont know why this language exists??! Also dont know why Petzold switched to C#. but still for hobbyist programmers, nothing beats VB.NET! 

Last thing - What the heck!!!!! Im using VS2008 and theres no tools in my toolbox when im doing VC++....???! What version are you using??! :O


----------



## krishnandu.sarkar (Dec 23, 2011)

I guess VC++ MFC and VC++ Win32 projects works in diff. way.

VC++ Win32 needs coding manually which we are talking about from the very beginning.

And may be MFC Projects are more like VB.NET / C#

As I remember learning VC++ Win32, you need to write raw code to do everything, draw windows using handles and all.


----------



## Skynaveen (Dec 30, 2011)

Vc++ or VC# is the best
They are very easy to use 
Can make very elaborate forms and gui
Looks like it will be supported in WP7


----------

