Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
clear a specific place on the Console by C++ 17 in vs2017, like this:
hello guys, I want to clear something, pls help me.
clear → want or clear → something else
Without refresh screen and using system("cls") or like these.
The C++11 standard (check some C++ reference site, then read the standard i.e. n3337) does not know about and does not mention screens. You can code C++ programs on computers without screens (e.g. web servers, embedded appliances, etc...), and notice that the standard output -e.g. std::cout - might not be a screen (think of redirections and pipelines), even on a laptop or desktop computer & OS (Windows, Linux, MacOSX, ...).
But many libraries might be useful to you. First, you can use OS specific libraries (e.g. WinAPI on Windows). You can also target a terminal emulator and use a library such as ncurses (or similar), and you might even output directly ANSI escape codes (I don't recommend this). And you could want to develop a GUI application with toolkits like Qt. You might even want to code a Web application (using HTTP server libraries like Wt or libonion, with more code in Javascript & HTML5).
I mentioned a few libraries, but you could find a lot more.
Be aware that terminals (and their emulators) are complex devices and their OS support is chaotic (for historical reasons). For POSIX and Unix read the Tty Demystified and see also termios(3). Have a glance at them even if you are using Windows, to feel how complex terminal emulators have to be.
In a comment, you mention "mouse". They are not known to the C++11 standard. My feeling is that an application handling the mouse should preferably provide a GUI (even if you could code a terminal application using the mouse thru other libraries or OS specific code), so I would recommend Qt (however, you might use some other GUI toolkit).
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I know that win32 API is written in C language and also why Qt is portable?
Could someone explain this to me?
Because WinAPI was not designed to be portable as it targets only the Windows OS while the QT framework targets multiple OS-es. The fact that WinAPI was written in C does not make a difference.
The windows API is portable in the sense of being processor agnostic (indeed, it has run on many non-Intel processors over the years). It is not portable in the sense of being OS agnostic; although even there Microsoft's is not the only implementation of the API. The wine project has done a credible job of re-implementing the API for other platforms, to the point that windows binaries will run, at least on processors that match the binary.
The fact that the WinAPI is aimed at C makes no difference.
Just because the language is cross platform it does not mean the library (especially in the case of those like WinAPI which are not in the standard library) are the same.
It's just a library that interacts with the video card/processor to make a GUI on a very low level. At this point it is so low level the process depends more on memory locations or processor specific operations. IE saying that certain memory locations (specific to the OS) will reference a pixel on a screen ect.
The Win32API has been built so that it only "knows" the tasks for computers with Windows OS, libraries like QT, once again are still not truly "cross-platform" they have just been built to include all the relevant operations needed for each OS it covers.
Why is a rather open question; but here's my take on it:
Win32 API is produced by microsoft; which has commercial reasons for not being portable.
QT is open source; which was created with the sole intention to be portable.
Bonus:
X11 is open source; which was created with the idea that the machine displaying the images might not be the machine running the program that wants the window. Which makes it inherently non-portable to other APIs that don't (eg windows)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Sorry if this sounds a bit newish. I am writing a cross-platform application to learn C++, which, if it turns out to work well, could help people. I would like it to be able to be used in two ways: by the designed GUI (may be using QT), or by command line for expert users who want to go beyond.
I would like to know how the communication between GUI application and the core should be made, since this is going to be open source and I want the code to be nice and clean.
Is there any commonly accepted way to do this?
There are a few approaches you could follow.
First write the CLI, then write the GUI as a standalone program that spawns the CLI version for all processing (via the system(), popen(), fork(), g_spawn(), CreateProcess() or similar calls). This may be a little more tedious than writing a library, but works well if you have already written the CLI, or in cases such as batch processing where the GUI is just a fancy form where you choose the parameters.
Split the application not into two, but three parts: library, GUI and CLI. The library would contain all the shared logic between GUI and CLI, such as handling input formats, editing operations, and so on. The GUI part would implement the graphical interface using the functions from the library, and the CLI would implement the command-line interface using the same library.
Make the GUI application accept command-line parameters, and avoid initializing the widget library if the passed parameters indicate that it is invoked in CLI mode. This is OK for a primarily graphical application such as a bitmap editor or a programming IDE that needs to expose some operations for scripting. Note that some extra hacking is required to make this work on Windows, see this answer. Also note that this will make it harder to run the app on servers that don't have a windowing system, since it will still have GUI libraries linked in.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I've written a C++ software that can be used from the comand line and that, obviously, can be compiled and executed in different platforms (Linux, Windows and Mac).
This software in particular is very simple, it just displays a menu in the command terminal with a few options, takes input files (.csv) acordingly, runs in a few seconds, and prints back output files (also .csv).
Now I would like to write a platform-independent GUI for it without changing my original source code.
Which is the best language? C++? Java? Does anybody have experience or recommendations on this?
Thank you very much!
You will always have to change some of your C++ source code, in particular because GUI toolkits are all event-driven so are based upon some event-loop (often provided by the toolkit library).
Alternatively, you might have the GUI be a separate program (starting your command-line thing), communicating with some form of IPC -often pipes- with the command line program, which you probably still would have to extend
I suggest to use Qt5, which is a cross-platform (Linux, Windows, MacOSX, Android, ....) graphical user interface framework library for C++. If possible, use a recent version of Qt and code in C++11 (since closures become very useful).
Another approach (which still would require architectural changes) might be to make your software become a specialized web server, by using some HTTP server library like libonion or Wt (or perhaps POCO); then the GUI would be any recent Web browser. You'll probably need some web coding skills (AJAX, Javascript, ...) and you'll better understand the relation between continuations and web browsing. (See also this & that).
If your software is running quickly enough (e.g. less than some fraction of a second) you could make its core processing be a callback function (or a Qt slot) of your GUI program. But you should not have a function running for more than a few tenths of a second (otherwise, the user interface won't be responsive enough), at least not in the main GUI thread. Otherwise, split the computation in several parts or slices (e.g. "idle processing" in GUI toolkits, with CPS & coroutines being a relevant concept) to be sure that the event loop is frequently (at least 5 or 10 times per second) restarted, or adopt a multi-threaded approach (with a compute thread outside of the GUI main thread), which brings painful synchronization issues (e.g. you'll use mutexes).
BTW, the good question is not the "best" language but to find a good-enough approach, library and framework.
If You know C++ try QT,
Or look for different cross-platform GUI solutions.
You could expose some RPC-like services, and have the front end query your C++ back end. This way you could code your UI in another language, or even expose it on a web interface.
If you know C++ well,using WxWidgets would be good option.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have had numerous bad experiences with GUI library
so I would like to know how to create a window from scratch in c++
I am not talking about win32, what I mean is basically create it myself without any external library
is there any way to maybe use a picture or something to create a window
yes I know how hard this will be.
also I read somewhere that library could be made for c++ in assembly
is there a way to create a custom gui in assembly or c++
EDIT:
I am aiming at just windows
PS: another reason I want to learn how to do this is because
I might want to actually create an OS. so I would want GUI with that...
In order to create a window you'll need to interface with whatever windowing system is currently present on your operating system. This will either require system calls if the window manager runs in kernel space (as is the case in Windows) or some sort of interprocess communication for user space window managers (like X). To create the window from scratch, you'll need to read up on how these window managers work and what protocols they use. In the case of X, it shouldn't be too hard to find resources on how the protocol works. In the case of Windows, your only option might be to use the API, since the internals of the window manager are proprietary.
You could try perusing the source code to MenuetOS - I believe it's written entirely in assembly and it has a GUI. Of course, this won't work if you're trying to write a program that runs on Windows, Linux, etc. But if you want to avoid all external libraries, including interfacing with Windows, you will have to run on the bare metal.
If you are crazy enough to do this thing in assembly go ahead and install masm32 , it can do basic GUIs like windows/messageboxes etc.
You create a window "from scratch" on windows, by calling the "CreateWindowEx" Win32 API.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'm looking for a minimal and easy to learn C or C++ cross platform gui library.
In a nutshell I only need the following functionality:
application window
menu bar
some simple dialogs, File-open and save. Maybe a user-written one.
user canvas where I can draw lines an circles on.
some kind of message/event loop mechanism.
Target platforms would be Win32 and linux. MacOS would be nice to have but is not important at the moment.
Why am I looking for something minimal? I don't want to spend much time to learn a big and full blown abstraction system for a really small application. The easier and leaner, the better.
Any suggestions?
If you need something small, try FLTK libs: I used them at work (embedded development) and I think it's a valid option. Maybe apps are not as "cool" as QT-based ones, but developing with FLTK libs is fast and easy.
I don't know about minimal, but Qt is pretty easy to learn.
Its light-weight enough to run on embedded devices, so you be the judge.
EDIT after seeing the comments:
Yes, Qt is a fullblown application framework, but here's my case: an app with cross platform GUI but other platform-dependent code is not really platform independent. I don't think moving existing C++ code into Qt entails any work at all. If anything, this would allow Nils to use his existing C++ code, and only use Qt for a GUI. But of course, I assume that the existing C++ code is portable.
wxWidgets (formerly wxWindows) is a widget toolkit for creating graphical user interfaces (GUIs) for cross-platform applications. wxWidgets enables a program's GUI code to compile and run on several computer platforms with minimal or no code changes. It covers systems such as Microsoft Windows, Mac OS X, Linux/Unix (X11, Motif, and GTK+), OpenVMS, OS/2 and AmigaOS. A version for embedded systems is under development.
http://www.wxwidgets.org/
See Good C++ GUI library for Windows for relevant answers.
Personally, I would go with Qt, now that it's open. You don't necessarily want a minimal library, you want one that is easy to use, and quality documentation and community support will give you just that.
Small projects have the nasty habit of sticking around and picking up scope -- as things get hairier, you don't want to be stuck with some small library that nobody knows about.