C++ open window hello world - c++

How can you write a C++ program to open a window like this one...
Is it possible or can apps only be ran from the command line?
I'm using the G++ compiler... Do I need something else like visual studio?
Can I do it just by writing code?

Take a look at Qt which is a cross-platform framework that easily builds GUIs.
Then check out a Qt tutorial, do a google search. Here is one that will get you to "hello world"
Also, you might want to check out Code::Blocks as an IDE. It will use your already installed g++ compiler.

You can use Borland C++, Visual C++ they has GUI or wxWindow or GTK library.

GUI programming requires the use of additional libraries. There is a C++ GUI library supplied by Microsoft for Windows called MFC. There are many other GUI libraries out there.
If you use these GUI libraries, you don't need to run the application from the command line.

Search for WinApi Tutorials like this one
there are alot
or you can also you the Visual Studio MFC application wizard and create a dialog application

Microsoft provides a tuturial for doing that:
http://msdn.microsoft.com/en-us/library/bb384843.aspx

The best and most low-level way of doing this would be by using the Windows API:
https://learn.microsoft.com/en-us/windows/win32/learnwin32/learn-to-program-for-windows
Microsoft itself provides excellent tutorials and documentation on how to program with their Windows Application Programming Interface, but there are also numerous other tutorials out there that can be found quickly with a google search.
To create a window like the one you ask about in the question, you would be looking for the following link:
https://learn.microsoft.com/en-us/windows/win32/learnwin32/your-first-windows-program
It might seem daunting at first, but the Windows API is extensive and provides a huge amount of functionality, on top of just creating GUIs. It would probably be worthwhile familiarising yourself with it if you are interested in Windows programming.

You need to use the Windows api from within C++.

Related

Use Qt codes in C++

I have some codes in Qt Creator that work properly. I need to use this codes but in win32 application in .net framework. Does anyone have any idea how can I do this? I am totally new to Qt and do not know how to use this useful codes in c++ project?
I appreciate any help in advance
I think I could not get my message across. Qt is c++ but It has some differences with the native c++ app that we use in .net framework. so I can't just copy all the codes in my project to run it properly. Can we make a dll or library to use this qt code in .net or not? and how can I do this?
I really need help. Thank you so much
For almost all cases, you do not want to mix .net and Qt in same application. It's less work to just take the logic and rewrite it for .net (managed C++ or C#).
Next best option might be to keep the parts separate and have them communicate through some IPC mechanism.
This is, because any non-trivial Qt code depends on it's own event loop, so getting the existing Qt code play nice with other event loop is always a hassle, and trying to get it play nicely when actual application is managed .net code... No, just no, unless you have a very compelling reason, are expert on both Qt and .net, and have extra time to make it work right.
I'm not sure if you don't know how to download and install Qt or how to create a Qt project in Visual Studio IDE. Try this installation guide.
Do you want to link the Qt library to your win32 c++ app? I think you should build the qt source code first with your win32 compiler. I think you could include the qt header and link the library as normal win32 library to your application after that.

Which C++ GUI library should I use

I'm developing a segmentation tool (for research purpose, not for commercial use) and I was wondering which graphical user interface should I use as there are many.
I'm looking for a relatively simple interface which allows me to do as follows on the same window:
*Input variables that will be used by the algorithm
*Browse a folder and select images
*Call functions by clicking on a button
*Display an image that will evolve while the algorithm is running
I'm coding in c++ with visual studio 2010 and I'm using additional libraries such as OpenCV, so the GUI library must be compilable and usable on console project on VS2010.
So far I've tried Qt, FLTK, GTK+ but Qt as compatible issues on x64 architectures, FLTK is lacking documentation and I'm not sure it answers to my needs and GTK+ wasn't working.
Thank you very much for any input and help you can give me.
Keep it simple.
If working with C++ on Windows with a "non-express" version of Visual-Studio, just use MFC.
The framework is mature and there are tons of reference, examples and samples on the web (codeproject, codeguru, MSDN, ... )
Have you tried OpenCV's own highgui?
http://opencv.willowgarage.com/documentation/python/highgui__high-level_gui_and_media_i_o.html
"While OpenCV was designed for use in full-scale applications and can
be used within functionally rich UI frameworks (such as Qt, WinForms
or Cocoa) or without any UI at all, sometimes there is a need to try
some functionality quickly and visualize the results. This is what the
HighGUI module has been designed for."
Also see: OpenCV and creating GUIs

Alternate of win32 framework for windowing system on windows

I want to develop a custom window system in c++ that should not depend on win32 library. As an example, Google Chrome has an interface that is not similar to windows own interface. Similarly MPCstar and adobe products have their own interfaces. Please help me where to start for such a project?
You can use cross platform
Qt
or
wxWidgets
but in my opinion Qt is better.
Qt is awesome even if you don't need cross platform support. I assure you after using it you won't understand how anyone could ever develop native GUI on frameworks like Win32 and MFC. Its only shortcoming is the size of the DLLs you'll have to distribute with your app.
BTW is C++ a prerequisite? if not, and you only need windows, use .Net.
I believe Qt should do the trick. I've never used it myself but it is platform independent. I know a few applications that use it, and it seems fine.
Qt and WxWidgets are the better options. And since its GUI I think Qt performs better and has greater support and lots of libraries.
Find Qt here!

Can you program a GUI in C++ that works on both Windows and Linux operating systems?

I have been learning C++ for a while now, and so far I love it. But I have been stuck at the console application level. I have built C# programs for a few years so I love having a GUI and not do everything via console.
Console programs when compiled will work on both windows and linux, which is great. When I was searching GUI C++ tutorials I could only find tutorials for windows specific GUI applications.
So my question is this, can you program a GUI in C++ that when compiled with run on both windows and linux? If this is not possible, can someone point me to a great place to learn windows and linux GUI?
I suggest you to use Qt by Nokia:
http://qt.nokia.com/products/
It is free, very powerful, very easy to use, and well designed. And there is also a Visual Studio Add-in available:
http://developer.qt.nokia.com/wiki/QtVSAddin
but you can use their own cross-platform IDE called Qt Creator as well.
You can use wxWidget library.
Yes, you need to use a cross platform GUI toolkit like WxWidgets
gtk and gtkmm http://www.gtkmm.org/en/
Indeed, using cross-platform GUI libraries (like Qt, Gtk, WxWidgets) help you to have the same source code working on Linux and Windows. I recommend Qt if coding in C++.
But there is no way to build an executable working on both systems (unless you use wine to emulate Windows on Linux, which I don't recommend in your case).

Creating GUIs for application

This is a question I've been wondering about for a long time.
How do you create an Interface for your program ?
It seems to much of a pain to position form controls and buttons using just code.
I'm looking for something similar to Visual Basic where you can drag and drop controls onto the window. But, I want to do this for applications written in C++.
Can It be done with compilers like MinGW on Eclipse ?
If you don't want to go the Qt route you can use ResEdit which is freeware. It will produce Win32 friendly .rc files that can be built with the MinGW resource compiler and used in Win32 applications.
There are some C++ Win32 wrapper libraries available though I'm not aware of any that are nearly as mature as Qt. I believe WinxGui is a port of WTL (or at least claims to be compatible with WTL) for GCC. It doesn't look like there has been much activity on the project site for a few years however.
What you're searching for is called Qt, both Eclipse and MinGW friendly.
Check out this nice article.
Qt toolkit is written in C++. So you can use it to develop GUI. It also comes with Qt Designer and Qt Creator IDE and tools.
Qt Reference Documentation
Qt Designer Manual
Qt Creator IDE and tools
And you can use MinGW to compile the code. You don't need to download MInGW separately. When installing Qt toolkik, it asks if you want to download MInGW also, just say yes to it. It will then download the correct version of MInGW itself.
The 1.7 GB download you look at is probably the full Qt SDK. This is not just Qt and documentation, but also includes the Qt Creator IDE with the Qt Designer "Form builder", the MinGW compiler, debugger, examples, demos, and some other stuff. There's also an "online installer" that allows you to select the packages you want before downloading everything. That's probably what I'd use if I were starting from scratch on Windows.