Skip to content

Update image content when window is resized/initialized #1331

Answered by tronical
second-reality asked this question in Q&A
Discussion options

You must be logged in to vote

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 siz…

Replies: 2 comments 9 replies

Comment options

You must be logged in to vote
4 replies
@ogoffart
Comment options

@second-reality
Comment options

@Pilyushkin
Comment options

@ogoffart
Comment options

Answer selected by tronical
Comment options

You must be logged in to vote
5 replies
@Pilyushkin
Comment options

@hunger
Comment options

hunger Oct 10, 2023
Collaborator

@Pilyushkin
Comment options

@ogoffart
Comment options

@Pilyushkin
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants