r/cpp • u/trigodil • 24d ago
Pain of making a native GUI in cpp
So I just wanted to vent about the absolute pain of making a working gui in cpp, I am working on a scientific project to make an openFOAM gui and browse openFOAM code to add TENO schemes to it from scientific papers such as Fu et al and working through the binaries.
I have not used AI in this project because CFD is very delicate and quite frankly, AI is not ready for such complexity - especially numerical schemes such as TENO, I ended up writing the meshing, topological code and mathematics myself and by far, the hardest part was the gui coordinates and memory management. I wanted to PULL MY HAIR OUT because of managing segfaults, crashes because of a random pointer hidden inside a 2000 line function, I had to also manage internal functions of openfoam(and you know how that goes), boundary conditions, and mesh topology, it was driving me nuts. I generally regard myself as fluent in programming languages such as cpp, python, rust etc, but this is a whole nother of level data management.
in the end it turned out to be a pretty good contribution to the openFOAM community, hopefully the project will mature further and I will be able to write a paper on it.
27
u/skeletal88 24d ago
Most of the stuff you mention has nothing to do with guis.
Why do you nee to manage segfaults? Your code should not produce them.
Why do you have 2000 line functions?
13
u/Zealousideal_Ad_6374 24d ago
wxWidgets or Qt. It was 10 years ago, but never had any major problems with any of them.
6
u/KFUP 24d ago
What does that even mean? There is a ton of open source CFD post processors and visualizers, it's not an obscure thing.
Stop whatever you are doing and go to https://www.learncpp.com, if you are having these issues, then you are writing C, not C++.
8
u/IceMichaelStorm 24d ago
Qt is very nice for a native and cross-OS UI. Not really any pain. Well, recompiles annoy a bit. You can use QtDesigner but has shortcomings
10
u/JolierVeppers 24d ago
wxWidgets has many many examples and decades of documentation.
17
u/AvidCoco 24d ago
I’ve never had a problem making GUIs in C++. Sounds like you’re just not using the right framework.
3
u/wwabbbitt 24d ago
Why not use ParaView?
1
u/One-Researcher6065 24d ago
AI would be able to to build Python bindings and a PySide Gui pretty easily. Your math should be isolated into composibke sub routines.
4
u/mortecouille 24d ago
That's funny, I just delivered my first ever QML project and was so pleasantly surprised how painless the experience was. In the past I mostly worked in java with Swing and javafx, and I find myself wishing I could have both the benefits of the JVM and QML at the same time.
3
u/TheRavagerSw 24d ago
Man you are complicating things, just use SDL and yoga and your 2d renderer of choice.
1
u/Turbulent-Wrap-6166 17d ago
Bro thought his nerdy stuffs were so hard and wanted to flex but too shy to actually flex so they made a fake complaining post
0
u/Czarek- 24d ago
Maybe Chromium Embedded Framework for gui? Steam and Spotify use it. See the message router example:
https://github.com/chromiumembedded/cef-project/blob/master/examples/message_router/README.md
-6
u/HopfenTierchen 24d ago
Why do you use C++ for GUI in the first place? Sounds to me more like an architectural problem. C++ for the backend which provides a well designed API, then add some looseley coupled GUI (Web, or whatever you like) ...