What is the best GUI tool to use for Rust?

If I wantted to make either Windows, Linux or Android GUI application using Rust, I wanted to know what is the best GUI tool I could use. I know there is plenty such as QT, GTK, imgui-rust (or whatever it is called) etc. However I am looking for a tool that is easy to use and is fast. What would be the most recommended tool to use?

3 Likes

I don't think there is anything like Qt in Rust. Unless you want to use Rust + Qt guide - Ritual

I think that if I really had to create a traditional desktop GUI application, with input/dialog boxes, check boxes, buttons, etc I would still do the GUI part of it it in C++ using Qt. Using the qtcreator IDE and it's gtdesigner drag-n-drop interface layout tool.

Then create an API between the Rust application business logic and the GUI. Or even run the Rust and Qt/GUI as totally separate programs communicating via some IPC.

In terms of the Model-View-Controller pattern that is Model and Controller in Rust, View in C++/Qt.

Of course doing all that us basically doing what happens between a web applications server and a GUI in the browser. So why not just do that, make your Rust program a web server, use the browser for all it's powerful GUI building features and HTTP and web sockets in between?

4 Likes

I just want to create a simple applicaiton that runs locally on the operating system rather than some web server and stuff.

Why would you prefer this over the Rust version? Is it because there is no qtcreator for the Rust verison you have mentioned?


Is there an alternative to Qt that would work well with Rust and it is simple to make the GUI applications either on Linux, Android Windows etc?

I do sympathize.

I have never found creating anything with a GUI, be it using Qt or GTk or whatever, simple.

Putting a web server in ones application is not really complicated and can be a surprisingly small amount of code when using an HTTP library like Rocket.

qtcreator is mostly just an IDE. Works brilliantly for Qt application code in C++. Traditionally I'm not a IDE kinda guy. Just give me any old editor. Now a days however I'd be using MS Visual Studio Code for C++/Qt development as I do Rust and pretty much anything else.

However, part of qtcreator is a drag-n-drop GUI tool for quickly layout widgets in a window. qtdesigner. Luckily qtdesigner is also available as a stand alone program, usable without qtcreator. I imagine it would be qtdesigner would be useful even if one were using Rust and the Qt bindings.

Now I don't know for sure but from comments I have read of reddit and elsewhere the Rust Qt bindings are not so easy to use. And that GTK bindings are easier, something to do with the difficulty of using C++ from Rust vs plain C.

Which is what put the idea in my mind. If using the C++ of Qt from Rust is so difficult then don't do that. Instead build the Qt GUI in C++ as usual. Write the application business logic in Rust. Because that is what we do around here. Set up a simple message passing arrangement between the Rust and the C++. Through that message passing arrangement send commands to the Qt GUI code to draw this and that. Get user input events back.

That messaging, command/event setup would be working at a much higher level than keyboard/mouse events and such. It would be sending the higher level application state down to the GUI for rendering and getting messages back that are meaningful for updating application state.

Kind of like what we do with a web server and client code in the browser....

2 Likes

Is that with any language or just with Rust?

Seems interesting, but honestly I don't feel like using some web server or running a web server, sorry man.

I see

Do you use these tools by any chance?

Oh that is no good.

Sorry man I didn't quite understand this bit.

Is there a C wrapper for Qt?

Interesting, but what is a business logic?

So when you say this you mean that it doesn't have as low level control if you are just using messaging passing thing?

I'm going to explore a couple of ways of doing this starting today, so it would be interesting to follow your process alongside.

I also like using Svelte, so I'm interested to look at solutions that combine this with Rust and support at least the main desktop platforms (Win/Mac/Linux).

This has lead me to select Tauri for a first hello world, and then web view directly as somebody suggested it might be easier than Tauri.

FYI I already did something for these platforms with a terminal UI using tui-rs (here).

1 Like

Joe232,

You have a lot there. So without requoting it all:

I believe making a nice GUI is just hard. In any language. Microsoft has not got it right yet after three decades, billions of dollars and hoards of smart developers on the case.

Aside: Back in the day I found a book on Intel assembler that included examples of how to use the Win 32 API in Windows 3.1 from assembler. I found that easier to understand than the MS documentation in C or C++ whatever it was.

I have used qtcreator and qt designer quite a bit. But that was all seven years ago or more. The last time it turned out that after spending weeks making something work nicely on the desktop customer demand moved to something they don't need to install or manually update, is readily useable on any Windows, Mac, Linux. Even tablets and mobile phones. At which point I gave up and started doing everything in the browser. Which is sweet in many ways, if you want easy 3D rendering there is webgl, if you want real-time display update there is web sockets, and so on. Also a pain in many ways, I hate HTML and CSS.

C++ is hard to interface to Rust, or any other language because of it's object oriented classes and such and the resulting binary interface required. C is much easier. Rust has a very good "foreign function interface" mechanism for the C ABI.

"What is business logic?" Good question. Basically it is whatever functionality your program is supposed to do. Not necessarily anything to do with money making business as such. Let's just say "application logic".

As regards messaging I mean to say that the messages relate to high level ideas in you application logic. Not any low level details of actually displaying and updating widgets it your GUI library. Or responding to mouse clicks on particular widgets.

For example. Imagine you application is some kind of appointments calendar. You application maintains a list of appointments for users with details of dates, times, locations etc.

Your GUI displays a calendar for a week or month or whatever and allows the user to add, remove update appointments.

The messages from your application to the GUI would include things like:

  • A list of appointments for a particular week and particular user, giving all details.
  • Notifications of changes to to appointments in the database.

The GUI would update it's display accordingly.

The messages from GUI to your application would include thing like:

  • User added/deleted/updated an appointment.
  • User requested to see a different week or month.
  • User requested to see some other users calendar,

The beauty of all this is that the GUI code is completely decoupled from your application code. You can totally change the look and feel of the GUI without messing with your application code. You could even swap the Qt GUI out for a GTK implementation. Whatever you like.

1 Like

Svelte can build GUI applicatons, right?

1 Like

Oh wow

I am surprised, I thought C/C++ would have been easier to understand over assembler?

Interesting mate.

Same over here.

I see.

Ah I get it now.

Right.

Makes perfect sense.

I see, that sounds like a better way to do things then.

Ha yes.

At the time I had only just heard of C++ and had not used C much. After having done a lot of work in other high level languages and a lot of assembler.

So I was not at all typical and I would not recommend it to anyone.

Well... Except when I get lost in the unfathomable jungle of complexity people can write into their C++ and even Rust code now a days, I start to yearn for the clearer, simpler, more direct times of assembler. :slight_smile:

You can do as much or as little as you like in Svelte. I'll be using it to handle the UI because having tried using it to build some web apps with a novel UI, it was the easiest and best thing I've ever used.

2 Likes

I can only imagine how horrible assembly would be to use.

I thought C++ and Rust would always be eaiser than Assembler?

Is this a crate? Glad it is easy :slight_smile:

Assembler can be very understandable, and simpler than C++. In small doses. Of course that does not scale to large programs.

Assembler can be fun. I once wrote an emulator for the Intel 8080 microprocessor in the assembler language of the Parallax Propeller micro-controller. The end result being I could run the old 8 bit CP/M operating system on the Propeller MCU. The challenge there being that in order get the full speed of the Propeller one only has space for 512 Propeller instructions to fit the 8080 emulator into!

What about in comparison to C?

Wow cool mate :slight_smile:

Even in comparison to C.

People can write some pretty impossible to understand C. For example:

main() { printf(&unix["\021%six\012\0"],(unix)["have"]+"fun"-0x60);}

From the The International Obfuscated C Code Contest

https://www.ioccc.org/1987/korn/korn.c

Lol I am surprised they even have such contests.

I've been satisfied with [fltk-rs]. There are informative tutorials for it on youtube.

2 Likes

Hi mate, I will check it out but I have one question, does it repetitively draw everything per frame? If it does, then this can potentially use a lot of CPU and battery power?

You can use gtk. Here is a very nice tutorial, second part of it as first part explains TUI:

3 Likes