Update image content when window is resized/initialized #1331
-
Hi, I'm trying to generate an image covering the whole window (a map viewer). Is there a way to automatically update it when main window gets resized/initialized? (something like an onResize event). Maybe there is another way to do things?
Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 9 replies
-
What you could try to do is change the property setup: slint::slint! {
import { Button } from "std-widgets.slint";
MainWindow := Window {
img := Image {
property <int> some_other_parameter;
source: build_image(self.width, self.height, self.some_other_parameter);
}
callback build_image(length, length, int) -> image;
Button {
width: 100px;
height: 100px;
text: "click here!";
clicked => { img.some_other_parameter = 42; }
}
}
} So basically the computed image depends on the width, height and some third parameter that I suppose affects what content is chosen. When the size of the window changes, build_image() is called with the same parameter value but other size. If you click the button, you change the parameter and source is re-computed by calling build_image again. |
Beta Was this translation helpful? Give feedback.
-
Good afternoon. He gave an example. What am I doing wrong?
|
Beta Was this translation helpful? Give feedback.
What you could try to do is change the property setup:
So basically the computed image depends on the width, height and some third parameter that I suppose affects what content is chosen. When the siz…