Making GUIs in C++ [duplicate] - c++

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
C++ library for making GUIs
I'm sort of new to C++, and I have made a couple simple programs, but the only way to run them is in the XCode compiler. I am wondering if there are any APIs or programs that can help me make a GUI for a C++ program and include any info if possible about that library. Thanks.

In general choosing a GUI library depends on:
The environment you are working on.
Whether you want your app to have a native look or not.
The IDE you are using.
Your expectations in terms of portability.
Which license you are ready to distribute your app into (GPL? LGPL? etc.).
So it's really hard to tell without knowing all these parameters.
Anyway, to name a few:
GTK+ / gtkmm
Qt
wxWidgets
FLTK
Fox toolkit
MFC (if you are using Visual Studio and want your app to run on Windows only).
I have used Qt in the past and it does the job pretty well and it's very well documented.
Also, from what I remember wxWidgets allows you to build GUIs that will have a native look on each platform.
[Edit]
My assumption about wxWidgets is confirmed by the following statement on their website:
Unlike other cross-platform toolkits, wxWidgets gives its applications
a truly native look and feel because it uses the platform's native API
rather than emulating the GUI.

This is a very broad question, but perhaps one of the most popular choices among many is Qt. It is powerful and importantly, cross platform.
Keep in mind it is a different ballgame if you mean GUI in terms of, say, a game interface - in this case you might need to look for something more specific, or even program your own - it's hard to tell from your question.

Is it so hard to ask uncle google and aunt wikipedia?
BTW take a look at JUCE. It's not as popular as metioned by others but it certainly deserves attention.

Since you're on Xcode, you have AppKit, the Mac OS X GUI library, available.
It will require using Objective-C or Objective-C++ but is very well integrated into that environment.

Related

GUI for C++ newbie

With few years of experience with Java I decided it's time to take the time and learn C++. I just compiled and run my first C++ with eclipse (of course) and would like to take it one step fw - I wish to build a GUI.
Question: what GUIs are available to C++, something that is an open-source and runs on Mac and eclipse.
Some have mentioned Qt, some wxWidgets.
A quick rundown on crossplatform gui toolkits that you could try:
Qt: Looks appropriately native on whichever platform you use it on. It has its own build system however, which doesn't always like to play nicely with others. If you want the "beginners" experience in making a GUI with Qt, I recommend Qt Creator. It's a standalone IDE built by the developers of Qt.
wxWidgets: While Qt looks native (it tries its best to emulate the look and feel of the OS you are running on). wxWidgets is native. That is, it uses the GUI elements provided by the operating system. Last I looked at wxWidgets the C++ library was falling behind as far as modern development practices go. You are possibly more likely to learn bad programming habits from this library.
gtkmm: This is from the same guys who make the GIMP and Gnome, which as a MacOS user probably doesn't mean a lot to you. They don't try nearly as hard to fit in as wxWidgets and Qt. However, they probably have the most modern C++ library. They have done a lot of work to use modern C++ development practices. This can be helpful for a new programmer, as you are less likely to learn bad habits from them. On the downside, you'll get thrust into the land of templates and function pointers and such.
Those are the big ones with the most momentum behind them. There are countless others to also consider.
Use Qt
http://qt.nokia.com/products/
http://qt.nokia.com/products/eclipse-integration/
I'd recommend Qt which is open source, has an easy-to-use API with GUI designer, and can be used on many operating systems (Windows, Mac, Linux..) and looks native on whatever it's used on.
You might want to take a look at wxWidgets or Qt:
http://www.wxwidgets.org
http://qt.nokia.com/products/
More generally, see here:
http://en.wikipedia.org/wiki/List_of_widget_toolkits#Based_on_C_or_C.2B.2B_.28including_bindings_to_other_languages.29
I've personally used wxWidgets and found it to be quite good, if you're after a recommendation.

Info on CrossPlatform

I have looked at some of the info on cross platform design. I can't find the answer to one question I have however.
What I would like to do is design my UI's in Delphi (Windows) and X-Code (Mac) with the underlying guts of the program being OS agnostic C++ code. Is this possible to achieve? I see lots of talk about Cross Platform Compilers, Frameworks and GUI tools but I really want to keep the interfaces 100% native.
Please forgive me if this an absurd question but I am relatively new to the world of programming and learning along the way. My company has an extensive catalog of Delphi applications for windows developed over the past 15 years and Delphi is where I have spent most of the last year.
If you are comfortable working with Object Pascal take a look to the FreePascal compiler and Lazarus which is a free cross-platform IDE (available for Windows, Linux, Mac OS X).
You should have a look at wxWidgets http://www.wxwidgets.org/ for programming 100%-native.
From my point of view I can't see the benefit of using two different and specific gui designers for two (or more) target platforms. It should be easy to share the code if the platform specific parts are clearly separated in your architecture. wxWidgets gives you the ability to use the same gui definition in both platforms without loosing the native character.
Personally, I wouldn't use C++ for UI design anymore. But why are you using two IDE's? I suggest to use a more abstract language (like Java with Netbeans/Eclipse or even better C#/.Net with VS/Blend) for this UI/event/interaction stuff keeping only some specific parts in an native optimized binary code.
.Net/Mono can use differnt toolkits for the ui style. Today, being "native" within the context of UX and look and feel does mean to follow system specific guidelines, I think.
This could be reached by views and adpaters (see google for some design pattern).
Look and feel is just a point of styling an app and it could be a native looking style, too. In the WPF-world handles are used only for the host window (and some legacy compatibility reasons using windows forms) but the user won't feel the differenc if you are styling your app like the former win-api-ones.
Qt has also an platform independent approach for the C++-world but is not really native. Qt draws its own controls with a native look and feel (if needed) and comes also with the option to use/share one definition of the UI between different platforms.
Your question is not absurd by any means - you're looking for the solution to a problem we've all been dealing with for many years - how to achieve cross platform compatibility and code reuse. But perhaps there are some points that you need clarification on:
As others have said, C++ is not the only 'OS agnostic' language - in fact most languages are 'OS agnostic' - what normally isn't (and cannot be) OS agnostic is the compiler, the GUI libraries etc. Pascal, C++, Python, C#, Java and many others have SDK's for various OS's, much of it open source.
If for some reason you are set on C++, check out Embarcedaro C++ - a Delphi clone using C++ instead of Object Pascal.
And IMO you should investigate Qt: http://doc.qt.nokia.com/latest/index.html - Qt is an excellent 'OS agnostic' framework that includes GUI widgets as well as many other powerful libraries that span pretty much the whole scope of modern PC computing.
Although c++ is the native language for Qt development, there are quite a few 'language bindings' available to make Qt programming possible with other languages. (varying degrees of functionality are supported depending on the binding implementation) I understand there is an Object Pascal language binding for Qt using Lazarus - I haven't tried it yet but it sounds very interesting.
Also, a word of caution: separating your GUI from the 'underlying guts' of your application such that it is OS agnostic can be quite challenging in complex applications - I think a good place to start is by reading up on the MVC paradigm.
HTH

Advice for C++ GUI programming

I have been writing C++ Console/CMD-line applications for about a year now and would like to get into windows GUI apps. For those of you who have taken this road before, what advice/tips can you give me. Ex: good readings, tutorials, approach tactics, etc...
I know this is a really broad question, but i really don't know how/where to start, thus not knowing how to ask this question properly.
I highly recommend the use of the Qt Libraries for several reasons:
The Framework is freely available for Windows, Linux, MacOS X, and a couple of mobile systems. Since version 4.5 the license is LGPL, which basically means that you can use Qt even in commercial applications.
The design of Qt is out-standing, e.g. they use modern design patterns and a very consistent interface design (I don't know many other libraries that use object-oriented ideas in such perfection). Using Qt is the same as using Boost: it will improve your own programming skills, because they use such beautiful concepts!
They are bloody fast, for instance in rendering (due to the different back-end for OpenGL, DirectX, etc.). Just have a look on this video and you see what can easily be done with Qt but is hard to achieve with native Windows, Mac, or Linux programming.
They have a really great documentation, with tons of tutorials and a very good reference. You can start learning Qt easily with the given docs! The documentation is also available online, so have a look and see by yourself.
As mentioned before, Qt is cross-platform; you have one source-base that works on all the important operating systems. Why will you limit yourself to Windows, when you can also have Mac and Linux "for free"?
Qt is so much more than "just" the user interface; they also offer network and database functionality, OpenGL bindings, a full-working web-browser control (based on WebKit), a multimedia playback library, and much much much more.
Honestly, I wasted a couple of years by developing software natively for Windows, while I could have been so much more productive.
For C++ you have two choices, Native or Managed.
For native development, my team (at Microsoft, in Windows) uses the Windows Template Library. It works very well for us.
You should learn the basics of Win32 and how Windowing works. The canonical tome is Programming Windows®
For Managed development you can use C++ with Windows Forms. However, windows forms has been supplanted by Windows Presentation Foundation (WPF).
Here is a good site that can get you up to speed.
This tutorial is useful
You can use Visual C++ 2008 Express Edition for your tools (they are free).
My best advice for Windows C++ GUI programming is don't do Windows C++ GUI programming.
I realize that is an extremely uninformative/smartass response if it's not qualified, so I'll note that you don't state that you need to do C++ Windows GUI programming, but that you "Would like to get into Windows GUI apps." If that is the case, and you don't have a very specific reason to use C++ (i.e. gigantic existing legacy codebase written in MFC or a bunch of C++ code that you want to build a front-end for but would be a pain to expose to .NET code), then it is going to be a lot easier and more productive to go the .NET route and start learning Windows Forms or better yet WPF using C# or another .NET language of your choice.
If you do need to go C++, then I would second the recommendations for 3rd party toolkits like Qt or wxWidgets, as the state of C/C++ GUI programming tools from Microsoft is now abysmal.
Most windowing libraries and technologies use similar idioms. Pick one and learn it.
The Windows Template Library is a very nice veneer for Microsoft Windows while sticking with C++.
For cross platform C++ windowing toolkits (they work on Microsoft Windows as well as other platforms) you can try QT or wxWidgets.
Well, for the Windows GUI, get used to referencing the MSDN a lot, assuming you want to deal with the API directly.
My favorite resource for learning the basics was theForger's tutorial, but there are hundreds of books and other sites out there.
I guess an important place to start is your toolkit. You tagged this visualc++, so I assume you are looking at that, however remember there are other toolkits like Qt.
I would suggest starting at Microsoft's tutorials.
+1 for Qt. I would put documentation at the top of my list of requirements for a GUI system. Qt has great docs and there's a huge community behind it. Also there are several books about it. Good docs are extremely important if you are working alone with no other team members to rely on. Alternatives are wxWidgets, MFC, WTL, FLTK and many more. They all have pros and cons. Eg FLTK is small and only provides GUI whereas Qt and wxWidgets also include networking, database access etc. Qt seems to have the most momentum at the moment after the Nokia buyout eg the release of Qt Creator which enables you to develop apps outside of Visual Studio.
It has been so long since I worked with C++ on Windows GUI, my word is always avoid C++ in Windows GUI unless you have a very good reason, I mean a good darn reason, if you need some performance C# is more than enough for 90% of the cases, and if you need more power write your performance critical thing in a C++ dll, and call it from a Windows Forms or WPF application.
It will save you hell of a lot time.
Still my opinion, if you have another I totally respect that
The first question is that do you want to develop Free, Open Source, for personal use or Commercial applications in C++?
If you want to develop for personal use! Then you can go with some good C++ Toolkit, Framework or API.
If you want to develop an GUI application that will be open source or free. Then you can go with C++ Toolkits, Frameworks or API's that have the GPL or any open source license that fits your needs.
Even you can develop Commercial applications with open source toolkits, frameworks or API's that have LGPL license.
The second question is that do you want to develop for the Windows, Mac, Unix or Linux? or these all, even for the mobile platform?
If you have a Windows user, as I am, and want to develop only for the Windows, I mean not for the cross platform, you can go with Win32 API, although, learning Win32 API is harder but it gives you the complete control over the machine. Believe me that no other tool would you provide the complete control over the machine. If you dislike Win32 API, for any reason, you can go with MFC, which is another technology from Microsoft, but is not free, old and has less attention now a days. If you decide to develop with .NET platform, you have C++/CLI, an extension to C++ language for developing .NET applications. .NET gives you the type safety, OOP and a built in garbage collector, provides you the all API's related to Windows and x86 or x64 machine in one package.
.NET has its own world! Microsoft has decided to port .NET to other operating systems too, Mono project is an example... You can develop nearly all kinds of applications using .NET.
If you want to develop C++ GUI applications for the cross platform, then Qt, WxWidgets and U++ are available for your help. You can write once and deploy anywhere with these libraries. Many open source IDE's and compliers are also available to develop C++ applications with ease. Note that if you do not want to develop for the cross platform, any cross platform library would be overhead and unavoidable increase in size of the executables.
Is your C++ knowledge is good enough to program software systems?
In fact, if your knowledge of C++ is not enough deep and you do not understand programming methods like OOP, Encupsolation, Classes, Interfaces, Types, Programming Patterns and so on, you can not use any toolkit with full potencial.
Do not forget that every Toolkit, Framework or API is implemented in some programming language. If you do understand the language very well, you can use the toolkit very well. I think, you would understand my point.
Put aside WPF or VC++ or Qt, You can also try out several libraries such as :
OpenFrameworks
Processing
...
there's an active project for developing Gui with Openframeworks here:
http://www.syedrezaali.com/blog/?p=2172
Are you familiar with Microsoft Visual Studio and .NET technologies? Since you want to develop for Windows platforms why don't you start by taking a look at Microsoft Visual C++ Express Edition.? Explore a little with the available tools from MS and search for some tutorials.
We are in 2020 but the question is still pertinent. I agree with Qt users, it's a great framework.
However, there is also C++Builder that offers you design GUI visually at design-time. C++Builder application can be built on both VCL (Windows only) and FireMonkey (cross-platorm) frameworks. Clang compiler can produce both 32 and 64-bits native executables. Community edition of C++Builder is free. Delphi integration is seamless: C++Builder project can include Delphi files directly and use any existing Delphi component packages and libraries.

Gui toolkits, which should I use? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I am writing a fairly large and complex data analysis program and I have reached the point where I think it is about time to build a GUI for the program. So my question is:
Which GUI toolkit should I use?
I am completely new to coding and building GUIs and would appreciate any guidance that can be offered. It doesn't have to be the simplest tool kit in the world, I learn rather fast. However, it does need to be able to do the following things (some if not all of these are probably incredibly basic for any given toolkit but I thought that it would be good to throw all this out there just in case).
It has to allow me to draw directly to the screen so that I can put graphs (spectra really), plots and things like them up for the user to see. I need to be able to collect position information on where they clicked on aforementioned spectra. I need to be able to display text and take text input from the user. It needs to be able to generate menus (you know File, Edit, etc). If it were to have some built in widget for generating tables that would be handy (though I can surmount a lack of that if I can draw directly to the screen). It needs to be able to pop up warnings, dialogue boxes, save and open boxes, etc. That is pretty much it, most of these seem pretty basic when I write them out but I don't want to get the GUI partly coded and then realize that I I need to rewrite it with a different toolkit.
It should be noted that I have written this program in C++ and that I don't want to have to write the GUI part in C or something else so the toolkit needs to support C++.
Additionally a cross platform toolkit would be preferable over a single platform toolkit. However if it must be a single platform toolkit then I would prefer it be for Linux.
Finally, I would DRAMATICALLY prefer an open source toolkit to a closed source toolkit.
Beyond that I cannot think of anything to add. Thank you in advance for your time and answers.
Hmmm based on the answers I shall look at both Qt and wxWidgets and see which appeals to me more. I with I could accept multiple answers as accepted but I can't, and since I am looking at two things it would be unfair to only accept one of the answers, perhaps in a week or two then I have looked at the toolkits and figured out which I want to use.
For C++, in my opinion, Qt is the least frustrating and most fully featured toolkit. Its also fully cross platform. Note that Qt will be LGPL licensed some time in March 2009, when version 4.5 becomes available. Currently, its only offered in a GPL and commercial license version.
Qt's GUI designer is good. It has lots of utility functions (scene graph library, translation support, built-in Javascript engine, built-in WebKit library). Via the MOC (a special pre-compiler) it also brings a few run-time binding capabilities and introspection to C++.
For your technical application, you might find that Qwt (http://qwt.sourceforge.net/) provides what you need. It is built upon Qt.
Qt can even be used "headless" if you want its utility support (such as networking, etc) without a GUI.
The other cross platform C++ option is wxWidgets, which is usable but not really comparable to Qt. Its a much lower level toolkit, and isn't as easy to use or fully rounded. Gtkmm is another option, in the spirit of GTK+.
Try WxWidgets. Cross platform (compile on Linux, Mac OS X, and Windows) and widely accepted.
http://www.wxwidgets.org/
Open Source too!
I see nobody commented on GTKmm. It is the C++ incarnation of GTK+, and it is a real pleasure to use. I have also used Qt, but I don't like the messy signal/connect code, the moc_XXX generated files, etc. GTKmm has signals and such, but not that preprocessing step, as well as almost all of the Qt toolkit can offer in the graphics arena.
I'd say it depends on whether or not you want the native Look and Feel of the OSes you're targeting for your application. Qt, like said earlier, is probably the easiest of the cross platform toolkits to use, however it is its own widget set. You don't get a native app look & feel unless you happen to be running on KDE.
I use wxWidgets at work. It can be frustrating at times and in some places not very polished, but it does give the native look and feel for the platforms you're targeting. It actually wraps the native UI controls to give them a common API on all platforms that wxWidgets is ported to.
I had the same question and searched for good GUI toolkits.
At the end I found out, that a GUI toolkit isn't enough - I need a complete platform independent solution providing me the build environment, IDE integration and lower level functions like network sockets and file I/O.
My result? Since nearly 9 years I use Qt (but the first years only for GUI stuff) - now I have highly complex networking apps with load balancing, massive multithreading and image processing.
You can use Qt as commercial user with professional support (like me) or just start your own projects under GPL and with 4.5 with LGPL (which allows commercial use).
The other alternatives like wxWidgets and GTK++ are very good choices for GUI programming.
But if you want a well documented and complete solution, then Qt is your choice.
Best Regards,
3DH
I'd also recommend wxWidgets together with DialogBlocks, which is a really nice visual GUI builder.
I will say that wxWidgets has a few rough edges, but the development community is very active and extremely responsive to bug reports / questions / contributions.
I use wxWidgets(toolkit) + wxFormBuilder(gui-designer) + eclipse(ide).
All tools are cross-platform and free.
Qt. Also you can use KDE which is built on top of Qt.

Should I use a cross-platform GUI-toolkit or rely on the native ones?

On my side job as programmer, I am to write a program in C++ to convert audio files from/to various formats. Probably, this will involve building a simple GUI.
Will it be a great effort to build seperate GUIs for Mac and Windows using Cocoa and WinForms instead of a cross-platform toolkit like Qt or GTK? (I will have to maintain a seperate Windows-version and Mac-Version anyway)
The GUI will probably be very simple and only need very basic functionality.
I always felt that native GUIs feel far more intuitive than its cross-platform brethren...
If you have the expertise, use native frontends, it'll effectively double the job you have to do for UI but from my experience non-native UI is a little bit clunkier than their native counterparts.
Have you looked at wxWidgets? Cross platform native controls.
I would agree that if possible, native front-ends are the way to go. I've not used wxWidgets recently, and I've heard it's come a long way, but back when it was wxWindows, we built an app with it that was spec'd to be built in X/Motif. When we finished the effort and delivered it, the customer said it did not look enough like X/Motif, and we had to re-work the entire UI at our expense... Joel Spolsky wrote a good article on this, but I can't remember the title. What he did say, IIRC, was the problem with Java and some other cross-platform UI was that "your dog barks at my app" - it's the little inconsistencies that annoy folks.
Cross-platform toolkits, more or less, all make the incorrect assumption that the difference between platforms is a matter of button placement and widget styling. In some cases you can get away with this - a Qt app will feel fairly native on both Windows (where UI conventions are very lax) and on Linux, particularly a KDE environment. In general, you can move between Linux and Windows relatively easily; conventions are similar, and the Windows community is lax about them.
Mac is the hard one. Its UI is built around an entirely different paradigm than either Windows or most Linux environments.
But in general, in a native app it's easier to speak the native language of the platform in more ways than just widget style.
Yes.
But seriously, it depends on your goals. I agree that the native UI libraries, with a bunch of effort put into them, will give vastly better results, but for lots of apps, a very basic UI is sufficient and a lot less effort if you take one of the existing cross platform frameworks.
Maybe starting with the CLI and getting functionality working makes the most sense for an audio conversion application.
I'm going to write my own cross platform application GUI layer for this soon.
Depending on the complexity of your application this can be a fraction of what is required for QT, GTK or FOX.
Reason is that we see a tendency that the platform vendors (Apple first) tries to design there system so that it looks unique. This makes it much harder for QT, GTK, FOX and other platform tools to constantly keep in sync with the latest widgets.
When the underlaying technique becomes more and more the same the OS vendors have no option then branding on look and feel of the platform.
wxWidgets used standard c++ syntax and preprocessor thus make you easily alter from plain C or C++. And will produce very native look where is appear, be it on GTK, X11, MS-Windows or Mac.
It's mature since 20yrs of 1rst release, has complete documentation with easy navigating, and supported by large community arround the world.
Coding in your favorite IDE or use prominent Eclipse-IDE and wxFormBuilder as GUI designer. Build wx library and IDE/Toolchain setup could be found on this link: http://yasriady.blogspot.co.id/2016/01/raspberry-pi-toolchain.html
Develop your application in Linux desktop and also provided compiler for Raspberry Pi2 (target application tested work smootly on Raspbian Jessie) ............