Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature?: Direct support for Qt-Designer (*.ui) files #5491

Open
antis81 opened this issue Jun 26, 2024 · 4 comments
Open

Feature?: Direct support for Qt-Designer (*.ui) files #5491

antis81 opened this issue Jun 26, 2024 · 4 comments
Labels
a:tooling Tools (mT,bO) enhancement New feature or request

Comments

@antis81
Copy link

antis81 commented Jun 26, 2024

Background

Few weeks ago I started wirting a little serializer fun tool that converts *.ui files into *.slint and *.qml (only latest Qt6) formats. Currently this is just for me to learn about Rust tooling. However the tool produces quite usable results in current state and I make good progress. The crate depends on quick_xml and serde to create the model(s) and yaserde for writing the output *.slint file (because quick_xml can only serialize into XML formats; not Slint).

Restrictions

  • Qt's custom widgets cannot be converted (and probably never will unless C++ can be reliably transpiled natively into Rust).
  • Connections are not supported (I think it is possible though)
  • Some widgets and properties cannot be converted without manual editing
  • probably more that I am not aware of right now

Make it a Slint feature maybe?

Assuming Slint would be able to read those Qt-Designer files (like a "JIT") and render them. Do you think this will benefit both projects Qt and Slint? I think in best case it might even make Rust more interesting for Qt/C++ developers, because it just feels like Qt and people wouldn't even have to learn a new language (when used with C++ bindings).

@ogoffart
Copy link
Member

Awsome. I think this tool could be usefull to migrate dialogs or some widgets from Qt widgets to Slint.

I'm not sure it should be integrated directly into slint.

It should probably be a tool can can be run once on your files.

I guess it could be a different build-dependency so the build.rs would look like:

// (this is pseudo code, naming need to be thought out and paths need to be relative to OUT_DIR and such)
qt_ui_to_slint::conver_ui_file("foo.ui", "foo.slint");
slint_build::compile("foo.slint");

And so this wouldn't be part of Slint itself but just another crate

Another solution i'm not suggesting is if you could do

import { Foo } from "foo.ui";

but that means we need to add support into Slint and keep compatibility.

Anyway, we could have that in our repository in the tools folder. Or you could just have it in a separate repository.

@antis81
Copy link
Author

antis81 commented Jun 27, 2024

Wow… actually I didn't think about importing a component directly from a "foo.ui". No question this would be really a powerful feature. Very ambitioned though (put in a single custom widget and… ⚡). Maybe with active support from Qt/KDE. Right now it's a dream, let's keep it this way (or at least mark this highly experimental 😸)…

The project repository lives currently on GitLab -> qt-ui-conv. When moving this into tools maybe I should start thinking about splitting out features (qt_ui_conv_slint, …qml, …cli, …gui?, …).

@ogoffart ogoffart added enhancement New feature or request a:tooling Tools (mT,bO) labels Jun 28, 2024
@WilstonOreo
Copy link
Contributor

I also think this tool would be very useful when migrating from Qt Widgets to Slint. However, I think integrating it into build.rs or exposing it as a component is not really necessary, because I doubt there can be 100% compatibility between the two frameworks. Which effectively means you will have to touch the generated .slint file. Or, what if you want to use slint-only features like built-in animations?
I guess a tool like slint-migrate-qt in tools with input .ui file and output .slint file is sufficient.
@antis81 The idea is great though, really would love to see the source of the tool :)

@antis81
Copy link
Author

antis81 commented Jul 4, 2024

@WilstonOreo The source is linked above if you like to understand the model. When you compile it you can run with cargo run qt-ui-conv -- <qt-ui-file.ui>. (In the examples folder you will also find some ui files or you can use your own to experiment with.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:tooling Tools (mT,bO) enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants