HakimLaxe
Posts: 16
Joined: Sun May 24, 2020 5:05 pm

Which library should I use to make a GUI?

Wed Sep 15, 2021 3:53 pm

I just need some advices by some skilled encorders.
I've to make a GUI in C++ that should work good on the Raspberry Pi Display screen, it's an university project so it's required to use C++ as a language.
I just searched a lot to find which would be the best option for my purpose: QT is the most popular option, but honestly set-up phase looks like really complex.
I can 't directly compile and run application on my Rapsberry but I need cross-compailing and secondary I just saw that to use external library a long and complex actionst have to be done.
I honestly prefer an higer encoding complexity (with some low level library comprared with QT) than compelixty related with installation and compiling phase.

I have tried ncurses.h, but it seems to be a really low level library and I was looking for something else.
Is there any simple llibrary that i may install direcltly from terminal with sudo apt-get install x and than using with g++ main.cpp -library_name ?

If possible i would like to avoid the use of some external framework

User avatar
B.Goode
Posts: 12965
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Which library should I use to make a GUI?

Wed Sep 15, 2021 5:10 pm

HakimLaxe wrote:
Wed Sep 15, 2021 3:53 pm
I just need some advices by some skilled encorders.
I've to make a GUI in C++ that should work good on the Raspberry Pi Display screen, it's an university project so it's required to use C++ as a language.
I just searched a lot to find which would be the best option for my purpose: QT is the most popular option, but honestly set-up phase looks like really complex.
I can 't directly compile and run application on my Rapsberry but I need cross-compailing and secondary I just saw that to use external library a long and complex actionst have to be done.
I honestly prefer an higer encoding complexity (with some low level library comprared with QT) than compelixty related with installation and compiling phase.

I have tried ncurses.h, but it seems to be a really low level library and I was looking for something else.
Is there any simple llibrary that i may install direcltly from terminal with sudo apt-get install x and than using with g++ main.cpp -library_name ?

If possible i would like to avoid the use of some external framework


If you were prepared to relax your requirement and start learning using the plain C programming language, Raspberry Pi themselves have literally published a book on the subject -
C & GUI Programming: https://magpi.raspberrypi.org/books/c-gui-programming


" I can 't directly compile and run application on my Rapsberry " Why not? That constraint is going to make things much more complex. (Maybe that restriction has been put in place by the assignment-setter to add to the challenge of the assignment?)

swampdog
Posts: 778
Joined: Fri Dec 04, 2015 11:22 am

Re: Which library should I use to make a GUI?

Fri Sep 17, 2021 3:06 pm

What kind of GUI? Are you going to be drawing the graphics primitives yourself or something high-level such as windows, menus and so forth?

Most things end up being "C" under the hood though so the lower-level you go, the more likely you are to be programming in C (and adding a C++ layer on top).

There's nothing, in principle, preventing you from using QT on an rpi4 (and similarly any other toolkit). The performance is quite acceptable provided you don't put everything into a single huge source file. Additionally, if you're not using the rpi hardware you can develop it on a PC and will only occasionally need to build it for the rpi - which can be done natively.

I'm still undecided about 'cmake' but it's what everyone is using and is the direction QT is moving toward in any case.

dsyleixa123
Posts: 1538
Joined: Mon Jun 11, 2018 11:22 am

Re: Which library should I use to make a GUI?

Fri Sep 17, 2021 3:31 pm

I agree to qt, especially to Qt5 Creator by which one can design GUI forms with mouse buttons, menus, graphic canvas, and other widgets via drag+drop, write own code using C++ in the IDE, and the built-in qmake works under the hood to build everything automatically ( just pressing ctrl-r to build and run or click the green PLAY button in the GUI IDE down left |> )
Last edited by dsyleixa123 on Mon Sep 20, 2021 1:02 pm, edited 1 time in total.

Heater
Posts: 18601
Joined: Tue Jul 17, 2012 3:02 pm

Re: Which library should I use to make a GUI?

Sat Sep 18, 2021 7:48 am

HakimLaxe wrote:
Wed Sep 15, 2021 3:53 pm
I just searched a lot to find which would be the best option for my purpose: QT is the most popular option, but honestly set-up phase looks like really complex.
Qt is not the simplest thing in the world to use but if you are programming in C++ nothing is going to be simple and Qt makes things about as simple as possible.

I'm not sure what you mean by "set-up phase. If you mean setting up a build environment to get your program compiled then that is a complex pain in C++ at the best of times. It's easy enough to create a new project in qtcreator and just start typing code. providing a simple(r) build system is partly what Qt is about.
HakimLaxe wrote:
Wed Sep 15, 2021 3:53 pm
I can 't directly compile and run application on my Rapsberry but I need cross-compiling...
Why can you not compile and run on the Pi itself? Installing the libraries and such to do so is simple enough.

The best thing to do is actually develop your C++/Qt application on your Windows PC or Mac. Then when it is in good shape and somewhat tested copy the project files to your Pi and build and run it there. You don't even need an IDE like qtcreator installed on the Pi to do that, just use the qmake and make commands.

Certainly you cannot develop any parts of your program that use Pi specific hardware but you can "mock" those out with test stub classes and such for running/testing on a PC/Mac.

Honestly, I have quite often been involved in cross-compiling projects. It can be very hard to set up and I would not want to do it again unless someone is paying handsomely. Conversely it is dead easy to install Qt on a PC or Mac and just get on with your project.
HakimLaxe wrote:
Wed Sep 15, 2021 3:53 pm
...and secondary I just saw that to use external library a long and complex actionst have to be done.
Where did you see such a thing?

If you are using the qtcreator IDE then getting your project built is as simple as clicking a button in the IDE. If you not then a simple "qmake" command followed by "make" does it.

Well of course you need a library to use Qt or any other GUI system.

What "long and complex" actions?
HakimLaxe wrote:
Wed Sep 15, 2021 3:53 pm
I honestly prefer an higer encoding complexity (with some low level library comprared with QT) than compelixty related with installation and compiling phase.
I don't understand. Installing Qt on a Pi is as easy as using the normal 'apt' commands to install packages. And as I said, the compiling phase is no more difficult than any other C++ project.
HakimLaxe wrote:
Wed Sep 15, 2021 3:53 pm
I have tried ncurses.h, but it seems to be a really low level library and I was looking for something else.
nurses is not a GUI library. It is for creating text based user interfaces that work in terminal screens.
HakimLaxe wrote:
Wed Sep 15, 2021 3:53 pm
Is there any simple llibrary that i may install direcltly from terminal with sudo apt-get install x and than using with g++ main.cpp -library_name ?
Qt can be installed from terminal commands with "sudo apt-get install x".

Nobody ever builds non-trivial programs by using the compiler directly with "g++ main.cpp -library_name". One typically sets up make files or uses make. Qt makes building projects easy with its qmake command.
HakimLaxe wrote:
Wed Sep 15, 2021 3:53 pm
If possible i would like to avoid the use of some external framework
I'm not sure what you mean there.

Arguably Qt is a framework. But as far as I can tell pretty much all GUI systems end up being very framework like. We can quibble about when a library becomes a framework but that is not very helpful/
Memory in C++ is a leaky abstraction .

m4r35n357
Posts: 124
Joined: Fri Jul 06, 2012 4:31 pm
Location: UK

Re: Which library should I use to make a GUI?

Sat Sep 18, 2021 8:25 am

No takers for WX?

https://www.wxwidgets.org/

User avatar
Gavinmc42
Posts: 6164
Joined: Wed Aug 28, 2013 3:31 am

Re: Which library should I use to make a GUI?

Sat Sep 18, 2021 9:11 am

Have played with this, if even I got it working then it cannot be too hard.
https://lvgl.io/

Not sure if a Python GUI is any use for you but this was the simplest.
https://lawsie.github.io/guizero/
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

Heater
Posts: 18601
Joined: Tue Jul 17, 2012 3:02 pm

Re: Which library should I use to make a GUI?

Sat Sep 18, 2021 10:31 am

Intersting. Do you actually have LVGL running on a Raspberry Pi?
Memory in C++ is a leaky abstraction .

User avatar
B.Goode
Posts: 12965
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Which library should I use to make a GUI?

Sat Sep 18, 2021 10:37 am

Gavinmc42 wrote:
Sat Sep 18, 2021 9:11 am


Not sure if a Python GUI is any use for you


Apparently not...
HakimLaxe wrote:
Wed Sep 15, 2021 3:53 pm
it's an university project so it's required to use C++ as a language.



(My own suggestion to refer to a C language text book was on the (possible inaccurate) basis that C could be regarded as a subset of C++ and therefore met the assessment criteria.)

User avatar
Gavinmc42
Posts: 6164
Joined: Wed Aug 28, 2013 3:31 am

Re: Which library should I use to make a GUI?

Sat Sep 18, 2021 12:06 pm

Intersting. Do you actually have LVGL running on a Raspberry Pi?
Someone else got it working in "baremetal", I just used their lib.

https://ultibo.org/forum/viewtopic.php?f=15&t=1456
It is is Free Pascal but it calls the compiled "arm-none" liblvgl.a.
C++ calling a Linux version of the lib should work.

Even ran in QEMU mode :D
https://github.com/Gavinmc42/LVGLDemo-QEMU-version

I need to spend more time with the graphing code, to see if I can mix it with other graphics like OpenVG.
https://github.com/Gavinmc42/LVGLchart.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

Heater
Posts: 18601
Joined: Tue Jul 17, 2012 3:02 pm

Re: Which library should I use to make a GUI?

Sat Sep 18, 2021 1:04 pm

Sounds line LVGL is not of use on a Pi using Linux unless one is prepared to put a lot of work into getting to actually display stuff, using X or direct frame buffer. Perhaps someone has already done that work.

I get the idea LVGL is designed for small memory constrained systems like micro-controllers with some kind of display attached, which is very interesting, but why not revel in the luxury of Qt on a full up Linux machine like the Pi?
Memory in C++ is a leaky abstraction .

jalih
Posts: 180
Joined: Mon Apr 15, 2019 3:54 pm

Re: Which library should I use to make a GUI?

Sat Sep 18, 2021 8:32 pm

Heater wrote:
Sat Sep 18, 2021 1:04 pm
Sounds line LVGL is not of use on a Pi using Linux unless one is prepared to put a lot of work into getting to actually display stuff, using X or direct frame buffer. Perhaps someone has already done that work.

I get the idea LVGL is designed for small memory constrained systems like micro-controllers with some kind of display attached, which is very interesting, but why not revel in the luxury of Qt on a full up Linux machine like the Pi?
I would be suprised if there is no SDL2 backend available to handle hardware accelerated drawing with KMSDRM driver.

User avatar
Gavinmc42
Posts: 6164
Joined: Wed Aug 28, 2013 3:31 am

Re: Which library should I use to make a GUI?

Sun Sep 19, 2021 1:24 am

Sounds line LVGL is not of use on a Pi using Linux unless one is prepared to put a lot of work into getting to actually display stuff, using X or direct frame buffer. Perhaps someone has already done that work.
No idea, but Framebuffer without X might be easier as that is what it is intended for?
For some tiny GUI apps a full /x11 Linux might not be needed.

Imgui works in VulkanSceneGraph, had that working on P4.
https://github.com/vsg-dev/vsgImGui
That's all C++
https://vsg-dev.github.io/VulkanSceneGraph/
Waiting for 1.1 conformance drivers before spending more time on it.

Worth a try on Raspberry Pi OS?
https://github.com/ocornut/imgui
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

dsyleixa123
Posts: 1538
Joined: Mon Jun 11, 2018 11:22 am

Re: Which library should I use to make a GUI?

Sun Sep 19, 2021 8:56 am

edit: missed the statement that the OP can't compile locally which would make Qt creator handling a bit more awkward (but not completely impossible)

User avatar
Gavinmc42
Posts: 6164
Joined: Wed Aug 28, 2013 3:31 am

Re: Which library should I use to make a GUI?

Sun Sep 19, 2021 9:10 am

Only took a few minutes to install Code::Blocks
It has a number of project templates, including QT4/5, wxWidgets, SFML, GLUT, GTK+, GLFW, SDL/SDL2.
Some of those have GUI's?
Have not used it much, don't do much C/C++ coding these days.

.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

RedMarsBlueMoon
Posts: 288
Joined: Mon Apr 06, 2020 3:49 am

Re: Which library should I use to make a GUI?

Sun Sep 19, 2021 10:15 pm

Iv'e just been shopping around for a nice simple C or C++ GUI framework too.
One that I liked the look of was 'nanogui' has anyone tried that? (https://github.com/mitsuba-renderer/nanogui)
Iv'e worked a little with Qt5 and yes it might take a little to figure out and there's bugs and maybe overkill for what you need.

User avatar
Gavinmc42
Posts: 6164
Joined: Wed Aug 28, 2013 3:31 am

Re: Which library should I use to make a GUI?

Mon Sep 20, 2021 1:17 am

Played with the base of it.
https://github.com/memononen/nanovg

And this one
https://github.com/Immediate-Mode-UI/Nuklear

More info here but again not C++.
https://ultibo.org/forum/viewtopic.php? ... lit=NanoVG
It is used as a linked lib so should still work?

Can run on most of those Code::Blocks templates?
https://dexp.in/articles/nuklear-intro/
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

jalih
Posts: 180
Joined: Mon Apr 15, 2019 3:54 pm

Re: Which library should I use to make a GUI?

Mon Sep 20, 2021 6:11 am

Gavinmc42 wrote:
Mon Sep 20, 2021 1:17 am
Can run on most of those Code::Blocks templates?
https://dexp.in/articles/nuklear-intro/
I would use Nuklear too as it's easy to use and works nicely without X11 with SDL2 backend.

Return to “C/C++”