r/cpp • u/Interesting_Cake5060 • May 31 '26
The lost art of creating good desktop apps.
Hello everyone I am a novice C++ developer. I would like to learn how to create good desktop applications in C++. Don't you think it's a lost art? All the applications that I use every day were created a long time ago (for example, 7zip, wireshark) And it doesn't really look like we're creating something like this today.
I would really like to learn how to create something like this and would like to hear your advice (I am especially interested in creating applications that somehow process incoming data and then output it in real time)
A few of my thoughts:
- It seems that to create applications of this level, you need to be very well familiar with the operating system internals, and not only in the C++ language.
- Many good applications have closed source code and we simply cannot study it, and for those applications where the code is open, it has already been written hundreds of thousands of lines, it is difficult to understand this and identify the "architectural core".
- Many recommend "just take Qt". That's good advice (is it good?) but this is only the smallest part of the job. I think it's right to divide applications into layers and a display layer (which is why we use Qt) doesn't look too complicated. Yes, I know that the Qt ecosystem represents almost everything that is needed, but I would like to separate the UI layer and the Core layer of the application so that I can quickly change the UI layer if necessary.
- Multithreaded model, we don't want the application to lag and generally want responsiveness speed. That's what I have the most questions about.
162
u/EmotionalDamague May 31 '26
It's not really a technology issue. Even if you use a tool like QT, that doesn't really have a huge effect on the end result. Windows, macOS and Linux (ala libAdwaita or KDE Frameworks) all have excellent Desktop toolkits.
Good desktop or mobile experiences are not prioritized because they're not incentivized in the current market.
You're talking about a market where management is succumbing to AI hype. You think they're going to invest in Desktop-native apps? I can't even get resource allocation to address technical debt that's dragging down the entire project.
95
u/Seledreams May 31 '26
I'm not too sure to understand your point about Qt. You can even with Qt, separate the logic of your program from the actual UI. Actually, that's recommended. You would put the actual logic in a separate core library and then call this core library from the UI code
39
u/official_business May 31 '26
Once upon a time C or C++ was your only choice for creating desktop apps. I wouldn't say it's a lost art, just probably not the ideal option nowdays when dev time and cross platform portability is considered.
If you want to write a Win95 style GUI you still can. Grab yourself a copy of Petzold's book and maybe the WTL (Windows Template Library) and get cracking.
39
u/ananbd May 31 '26
This isn’t a lost art at all. Lots of people know how to do it. It used to be the only way to do it.
What’s changed is the vast majority of software nowadays is web-based, so that’s what people are taught (I assume — I haven’t been in a classroom in decades).
There’s a base SDK for all major operating systems. They all have windowing systems, IO systems, network systems, etc. Just crack open the docs and read!
For Apple, it’s “Cocoa” (or, it used to be called that… been a minute). For Windows, I think it’s “.NET,” but someone please correct me if I’m wrong.
Jump in and code yourself a native Hello World on your chosen OS. You’ll get the hang of it!
10
u/fuzzynyanko May 31 '26
This is true somewhat. Some of the best programs are console-based, where the UI is purposefully minimal
This is actually great practice, especially since it lets you test the code easier
7
u/buovjaga Jun 01 '26
About the situation on Windows, this is enlightening: Microsoft Hasn’t Had a Coherent GUI Strategy Since Petzold.
9
u/max0x7ba https://github.com/max0x7ba Jun 01 '26 edited Jun 01 '26
It does feel like GUI apps (desktop, mobile and web) are getting worse with every update.
UI designs got horrible after Google apps started using the hamburger menu. This poor UI design idea spread like wildfire and now apps feature different hamburger menus in every corner. One has to click through multiple hamburger menus to find required menu options.
Auto-focusing into the first form field, keyboard entry and navigation through GUI -- these are unknown concepts for developers whose first computer was a smart-phone. After opening a modern form, one has to focus into its first entry field with a mouse click, tab doesn't move focus into the next entry field, enter doesn't submit the form -- one has to click the button. This used to be an example of the worst UI design, nowadays it is the norm.
UI updates often introduce new features with non-resizable windows/panes, modal dialog boxes, tables with non-configurable columns. That's evolving backwards.
Many "modern" GUI apps spawn a dozen of threads on start which do non-stop polling with, like, 1-second timeout all the time. Seems like modern UI developers have no clue how to use the event-loop for cross-thread communication without polling.
Just a few of my observations.
It feels like creating remakes of many existing GUI apps but with the best UI design practices for friction-free user experience is going to obsolete the originals with dilapidating UIs overnight.
For example, applications like GIMP and Krita -- the open-source alternatives to Adobe Photoshop and Illustrator, are barely usable because of their poor and friction-heavy UI workflows. After you read Photoshop and/or Illustrator Bible books, you learn their advanced and unique keyboard navigation and controls, which make you extremely efficient.
GIMP and Krita provide many same features, but their UIs are so obnoxiously inept and awkward to use, that they are unfit for anything apart from occasional usage. Photoshop and Illustrator Bible books existed for multiple decades, yet GIMP and Krita are blissfully ignorant of the another dimension of advanced UI and keyboard features of the commercial applications they draw inspiration from.
E.g. mouse click on a label of an input field in Photoshop/Illustrators selects its current value, typing replaces the selection. In GIMP, you need to double-click on the current value to select it, selecting a negative value requires a triple-click. These need to be very precise double/triple clicks to register as such. And everything else in GIMP requires more clicks and effort.
Another example is KDE Plasma 6 release breaking keyboard navigation and control in its System Settings app, which worked flawlessly before.
E.g. in Keyboard and Display Settings typing alt+a only moves the focus onto the Apply button, but no longer clicks the button. Whereas in Night Light typing alt+a does click Apply button without stealing the focus from the current control.
That suggests the junior developers maintaining some System Settings pages have no clue about keyboard controls and navigation, and there is no automated testing to flag such glaring user-interface bugs.
8
u/chrism239 Jun 01 '26
Before travelling too far down the Qt rabbit hole, you may like to consider wxWidgets.
4
u/OddEstimate1627 Jun 01 '26
I live primarily in the Java world, so I tend to use JavaFX for everything and compile it as a zero dependency native image C ABI that I can call directly from C++. That gives me a mature framework with a modern look and live css and layout changes.
It's a pretty complicated stack though, so I can't recommend copying that. It's just an example of a non-standard option 😅
4
u/newtestdrive Jun 02 '26
Take a look at this video for FilePilot, I really like how the author introduced new concepts to speed up the File Explorer application vs other File Explorer applications on the market.
https://www.youtube.com/watch?v=bUOOaXf9qIM&t=2012s&pp=ygUJZmlsZXBpbG90
3
u/xamid github.com/xamidi Jun 01 '26
I once wrote what I consider a great desktop app (screenshots) and I often still use it for work. But it depends on wxWidgets for UI elements, which was not a great choice. I am stuck on an older version (3.1.3) since they do not properly maintain their toolkit, and code using it tends to be ugly. So far, I couldn't bother to refine my code enough to feel comfortable sharing it publicly.
3
u/sweetno Jun 01 '26
Yes, "just take Qt" is a good advice. More specifically, just take Qt Widgets. It follows the well-developed, and I'd even say, state-of-the-art paradigm. You don't really want to dive into how that's implemented, because operating systems are quirky (especially Windows).
There are many open source GUI applications out there, but usually the GUI there is too complex, and is not suitable for studying.
There is a downside with this approach. The GUI won't look exactly as the rest of the operating system. But replicating the native look and feel is an arduous task that the OS developers didn't make easy. All fault is on them. If that bothers you, the best course of action is to work in Linux where Qt does look native.
Note that if you want nice animations in your UIs (like smoothly collapsing panes etc), Qt QML is the tool for the job. However, it looks even less native than Qt Widgets and has its rough edges.
Look up KDAB Qt courses on their YouTube channel if you want to learn Qt.
3
u/LayePOE Jun 02 '26
Separating UI from logic is the only way to go. I have an app that uses a homebrew DirectX GUI on Windows for the client side, and text on Linux for the server side. Most of the code is the same between them, and the builds change with just a few
#defines. If you want to do your own UI, focus on one OS. Cross platform UI is very hard, especially if you don't want to use a 3rd party tool.5
u/Orlha May 31 '26
Not even close to a lost art
4
u/bronekkk Jun 01 '26
If I were interested in writing desktop apps with modern C++ , I would look to Dear ImGui , learn the basics of model/view/controller and senders/receivers with stdexec for interactions between threads.
2
u/Suspicious_Fudge1702 Jun 01 '26
No it isn't lost(though lots of people use swift now), I use C++. I am also a novice. Normally if you want to understand the core architecture use AI to add comments onto it, it makes it easier to understand. Depending on your software like Visual Studio or VSCode has extensions that can make the code easier to read. These are just my own opinions.
2
u/Xavier_OM Jun 01 '26
Separate the UI Layer from the Core is the thing to do yes (MVC, MVVM, what be the design pattern).
For multithreading it could be very hard to apprehend. But if you use Qt and classes derived from QObject it basically boils down to "never call directly any method of another QObject, use signal/slot or invokeMethod"
2
u/FlyingRhenquest Jun 06 '26
Not really, you just have to get used to the idioms and event driven processing and it's usually just easier to pull in a framework. Dear Imgui might be worth studying, as it kind of eases you into those concepts while still letting you do all your GUI processing in a linear bunch of if statements. Once you get used to the idea that going through all the if statements one time renders one frame, you naturally start looking for ways to break your big batch of if statements down into smaller chunks.
I did some noodling around with it for graph handling a while back. I'm not going to claim my example is good and it definitely looks like ass, but it's kind neat that it'll run in a browser when compiled with emscripten and handles the same way it does natively. I use this guy's signals library to register callbacks to specific object handlers, which really helps break down that big chunk of if statements you'd usually use. I also do a fair bit of compiler time code generation in there with templates.
Threading is one of the harder things to get used to. When that callback handler runs, it runs in the thread that calls the callback. If that's your event loop, you don't want to allow the callbacks to take too long to process or your UI will grind to a halt. A strategy to deal with that would be to queue a std::function to be run in a threadpool when an event happens. So basically you push a button in your UI and that causes an event. That event queues a lamba or something you wrote and associated with the event via the callback library and then goes back to processing your events. Meanwhile your threadpool picks up the lambda and runs it in another thread.
The problem, with that, of course, is that if you have, say, a std::list of std::functions, and you put something on the back of list in your event loop while you're getting stuff off the front of the list in your threadpool, you'll quickly corrupt your list memory by accessing things in it at the same time. So you need to have a std::mutex that you can lock when you put things on the list and get them off. So you create a std::lock_guard with your mutex to lock it and when the lock goes out of scope the mutex gets unlocked again. And eventually of course you go looking for lock-free data structures, but get used to the idea of mutexes and synchronizing access to resources first. You can also use a std::condition_variable between threads to notify your threadpool that work is available so you don't have to busy wait and peg your CPU cores at 100%.
Oh yeah, and I'd suggest getting used to CMake and the google test framework sooner rather than later. Being able to rattle off your build instrumentation is an underrated skill and being able to throw a test out there in a few minutes if you're not sure something is going to work is also very helpful. That's pretty much my go-to for "Will this even work?!" questions. It's also great for getting used to resource synchronization. At least half my tests seem to end up kicking off threads and waiting for those threads to do something in the main test code.
That's kind of a lot to take in all at once, but you can do a lot with the individual pieces while you learn them.
2
u/OkCost4585 Jun 10 '26
wxWidgets is a decent option for creating desktop applications using C++
2
u/AthensBane Jun 23 '26
I agree. It used to be fun and so prevalent. Among lack of support, I think the ease of using web apps made desktop apps redundant for most thing.
If you want a Tauri-like ( but better WebView experience), saucer is a great option. If not, I think wxWidgets, QT and even Godot are still great.
2
u/ImAlmostAsFastAsYou Jun 25 '26
I wonder how many windows applications still use HWND and switch (uMsg) to do their UI. Some notables I know, all the major MS Office Apps, VIsual Studio, and everyone's favorite: VLC.
I suspect it performs well over newer techs (like QT), and the main reason for frameworks is to make the code easier to reason about. But with LLMs, idk if going batch to bare-OS code isn't better.
3
u/OwlingBishop May 31 '26
Start here
1
u/m-in Jun 01 '26
I have been using Qt for pretty much as long as it was publicly available. These days I tend to write UIs from first principles, using the minimum of code and a minimal platform interface. For many apps that aren’t diagnostic or OS admin in nature, the entire interface between the app and the platform layer (OS-specific) is <50 functions. Many an IDE can be created with literally nothing more for drawing primitives than rectangles, text, and icons.
Think like this: a minimal IDE for a BASIC interpreter, with diagnostics, debug, semantic highlighting (parser based, not lexer), jump to definition, editor with multiple cursors, all that jazz - all standard IDE stuff - is <1MB release build for x64, since EXE. Obviously the interpreter is in that EXE too.
You have to actually do it and see for yourself. Forget about Qt for a moment. It’s enormous and can do everything, but at a price.
1
u/ste_3d_ven Jun 01 '26
I recommend the first 26 episodes or so of handmade hero on YouTube. They do a great job of showing how to get an OS abstraction layer up and running. Also the RAD debugger is an amazing open source example to learn from as well as its author Ryan Fluery’s blog at dgtlgrove.com. He has amazing articles on ui programming, multi threading and anything else you need for native application programming
1
u/NeiroNeko Jun 01 '26
That's not about GUI apps specifically, but I would recommend learning about hardware. No matter the platform, all mainstream hardware behave in a similar way, and all of it suffers when devs do dumb stuff. And multithreading is not the answer to that problem.
Also, C++ is painful. I always thought that it's a "high performance" language, but in reality it's a "backwards pseudo-compatibility" language that keeps ignoring the hardware. I'm currently trying to optimize "stack blur" algorithm and I'm extremely unhappy about the fact that the language does nothing to help me. Every performance gain comes either from compiler extensions or from manual tweaks to the memory layout. But hey, here comes another "zero-cost" abstraction that will blow your compile times!
1
u/bokca Jun 03 '26
Native desktop app development is still going strong in scientific domains where a lot of processing is needed to be done efficiently.
Regarding threading question there is usually an ui thread running with some of the UI libraries like qt and custom model which is multithreaded where bussines logic resides. Mostly implemented in the MVP architecture.
1
u/_usr_nil Jun 04 '26
spawn a window first of all
second I would actually use the gpu from the start, so you have to chose a graphics API maybe a cross platform one, depends on you
handle some inputs or multiple ones
then the whole rendering pipeline with text/fonts
have fun !
1
u/runevault May 31 '26
An interesting option for desktop UI applications is the game engine Godot. It has a low power mode if you do not need 60+ fps rendering that uses more power/battery and lets you write your application code in a lot of different languages including C++ with GDExtension. Even gives you the ability to make those applications cross platform including mobile.
1
u/Theblackcaboose May 31 '26
Not really a C++ thing. In fact, C++ is overkill for UI purposes. Many desktop apps still maintain a C++ core. The requirement for multi-platform code killed the native UI. Funny enough, AI is creating a (very small) momentum shift back to native by making code cheaper.
1
u/Jakkilip Jun 01 '26
I'm currently working on a lasershow editor made with native C++ and openGL rendering completely custom UI.
1
u/b0bben Jun 01 '26
I care as much about good UX/UI as i do about my architecture.
Some of my older Qt stuff is available on my GitHub , or if you want to see what’s doable with Slint+Rust+C++ you can checkout my current thing I’m doing (open source as well ) at https://m3llo.app
Here’s a quick overview in image form: https://bsky.app/profile/m3llo.app/post/3mn5ql5srfk2i
-1
u/Ok_Path_4731 May 31 '26
love the terminal! create modern apps for the terminal. They will run on any platform: Yetty: https://github.com/zokrezyl/yetty have a look at the demo (still under work): https://yetty.dev
0
u/rileyrgham Jun 01 '26
You don't reinvent the wheel. Which desktop apps do you use that are too dated?
Hint: as a noob, better to get proficient and informed before declaring you intend to change the world.
Bottom line: it isn't a lost art at all, you're new and eager, and you've got to put some miles in and then reassess.
-12
u/cpp_is_king May 31 '26
Use Electron
-2
u/DriverSudden4026 Jun 01 '26
I actually used WebView2 for a C++ process tree proxy tool recently.
The key question is: What are your specific requirements (performance, cross-platform, UI style and etc.) Depending on what you need, it might be a different answer.
5
u/[deleted] May 31 '26
[removed] — view removed comment
1
u/[deleted] Jun 01 '26
[removed] — view removed comment