This template introduces support for compile-time Qt Designer UI files.
Details
- Reviewers
vandenoever - Commits
- R881:b94a08227773: Widgets cargo template with UI support
execute "cargo run" from the templates/qt_widgets_cargo directory.
Diff Detail
- Repository
- R881 Rust Qt Binding Generator
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Noted a couple tweaks to the ui file support.
src/build.rs | ||
---|---|---|
487 | Since an application can specify multiple ui files across arbitrary source directories, generating the output in the same directory will cause issues if the ui files have the same name. | |
494 | Since the generated ui header will be included within other c++ files in the application I don't believe it should be added to the list of headers. That causes it to get run through moc which is likely not necessary since the including file will be run through moc. |
Allow ui files with the same name from different directories.
Don't run generated headers through moc.
This patch works fine. Support for .ui files is a great addition.
I see an opportunity to make it a bit more interesting. You use ui.mesg->setText(simple.message()); to set a UI value once. This template only uses one method of the Rust code.
If you add QLineEdit and connect some signals and slots this code help somebody that starts from this template more, since signals and slots are nearly always required.
templates/qt_widgets_cargo/src/implementation.rs | ||
---|---|---|
13 | You probably want this to be message: String::from("Hello World!"). | |
20 | This should be self.message.as_str() of &self.message. |
Changed widgets and added more interaction between widgets (as suggested).
One challenge I'm noticing and don't have a good solution for is that there's no good way to specify the main.cpp's dependence on ui_main.h. The header is updated when building after modifying the ui file, however, the buld.rs script doesn't know that it then needs to recompile main.cpp since it's included there.
The workaround is to touch the dependent file (main.cpp in this case).
I looked but couldn't find a mechanism that would allow for passing the message content in the message_changed signal. It would be nice if Simple::messageChanged could be connected directly to QStatusBar::showMessage instead of having to write the lambda (minor nit).
I like the new version.
One challenge I'm noticing and don't have a good solution for is that there's no good way to specify the main.cpp's dependence on ui_main.h. The header is updated when building after modifying the ui file, however, the buld.rs script doesn't know that it then needs to recompile main.cpp since it's included there.
The workaround is to touch the dependent file (main.cpp in this case).
Another solution is to add ui_main.h to compile_inputs.
I looked but couldn't find a mechanism that would allow for passing the message content in the message_changed signal. It would be nice if Simple::messageChanged could be connected directly to QStatusBar::showMessage instead of having to write the lambda (minor nit).
Right, it's an option to change that. A consideration is that always passing the new value has some performance overhead for converting the rust value to a Qt value.
add generated ui header file paths to the list of compile inputs. This triggers the library to be rebuilt when the ui file has been modified. Thanks for the suggestion.
This patch looks good now. I can land it for you.
To do so, I need you full name and email to amend the author information. Shall I use the name and mail from the mail that you sent me?