slint icon indicating copy to clipboard operation
slint copied to clipboard

Support for multiple windows

Open DBLouis opened this issue 3 years ago • 1 comments
trafficstars

I could not find a way to instantiate multiple windows. Is this currently not possible?

DBLouis avatar Jun 28 '22 15:06 DBLouis

It is possible, but it's a little tricky.

Suppose you have MyWindow1 := Window { ... } and MyWindow2 := Window { ... } and want to show them. To overcome #784 you could put say MyWindow2 into a helper crate, build it using build.rs and export it. Then in your main crate you can import MyWindow and then write something like this:

fn main() {
    let my_window_1 = MyWindow1::new();
    let my_window_2 = helper_create::MyWindow2::new();
    my_window_1.show();
    my_window_2.show();
    slint::run_event_loop();
}

I haven't tested this, but this might work as workaround until #784 is resolved.

tronical avatar Jun 29 '22 07:06 tronical

Closing as the main issue is tracked in https://github.com/slint-ui/slint/issues/784

ogoffart avatar Nov 29 '22 12:11 ogoffart

It is possible, but it's a little tricky.

Suppose you have MyWindow1 := Window { ... } and MyWindow2 := Window { ... } and want to show them. To overcome #784 you could put say MyWindow2 into a helper crate, build it using build.rs and export it. Then in your main crate you can import MyWindow and then write something like this:

fn main() {
    let my_window_1 = MyWindow1::new();
    let my_window_2 = helper_create::MyWindow2::new();
    my_window_1.show();
    my_window_2.show();
    slint::run_event_loop();
}

I haven't tested this, but this might work as workaround until #784 is resolved.

I don't know how to do it, can you leave an example?

Davidc2525 avatar Jan 14 '24 21:01 Davidc2525

It is possible, but it's a little tricky.

Suppose you have MyWindow1 := Window { ... } and MyWindow2 := Window { ... } and want to show them. To overcome #784 you could put say MyWindow2 into a helper crate, build it using build.rs and export it. Then in your main crate you can import MyWindow and then write something like this:

fn main() {
    let my_window_1 = MyWindow1::new();
    let my_window_2 = helper_create::MyWindow2::new();
    my_window_1.show();
    my_window_2.show();
    slint::run_event_loop();
}

I haven't tested this, but this might work as workaround until #784 is resolved.

I loved slint until I saw that you can create multiple windows, I tried the popupwindow and it turns out that if you open one popup inside another the app freezes

Davidc2525 avatar Jan 14 '24 21:01 Davidc2525