Iβm a beginner β I can't create a second window in Slint, please help π #9013
-
Hi everyone π Iβm new to Rust and Slint, and Iβve been trying to open a second window in my application β but I just canβt get it to work. I've tried using SecondWindow::new() and calling .run() or .window().show(), but nothing seems to work. main slint::include_modules!(); fn main() -> Result<(), Box> {
} I also tried adding a callback like this in my .slint file: `export component AppWindow inherits Window
also
`fn main() {
}` fault My questions:
I'm totally stuck and would really appreciate any help π Thank you in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
If your second window is in its own slint file, then you need to export it from your main slint file to be able to use it from Rust.
export { SecondWindow } from "second-window.slint";
export component AppWindow inherits Window {
// your code
}
export component SecondWindow inherits Window {
// Your code
} Hope this helps |
Beta Was this translation helpful? Give feedback.
-
Do you have a piece of code on how to open and close windows? |
Beta Was this translation helpful? Give feedback.
-
You can use this code in a callback handler. let second_window = SecondWindow::new()?;
second_window.show()?; I attached a small working example. |
Beta Was this translation helpful? Give feedback.
-
Yes. I attached the example this time with two windows opening. |
Beta Was this translation helpful? Give feedback.
Yes. I attached the example this time with two windows opening.
multi-window.zip