slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.56k stars 604 forks source link

How to put component in the center of screen? #4236

Closed newtome8888 closed 10 months ago

newtome8888 commented 10 months ago

I am using slint in Rust, I have a very simple question: How to put my component in the center of screen? Usually, in other libraries such as SDL, I can implement it with the formula: x:screen_width/2-self.width/2, y:screen_height/2-self.height/2. But there is no way to get the screen width and screen height in slint. What should I do?

Vadoola commented 10 months ago

This will probably point you in the right direction: https://github.com/slint-ui/slint/discussions/3859

ogoffart commented 10 months ago

Thanks for filling an issue, and thanks @Vadoola for answering it. Closing since this is duplicated with the discussion #3859

(Note: for such question, please use the GitHub discussion instead of issues which we use for bug report and feature request rather than questions)