slint-ui / slint

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

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

Closed newtome8888 closed 8 months ago

newtome8888 commented 8 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 8 months ago

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

ogoffart commented 8 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)