slint icon indicating copy to clipboard operation
slint copied to clipboard

Add support for custom scale factors to the Qt backend

Open tronical opened this issue 2 years ago • 2 comments

The Qt backend uses the device pixel ratio Qt determines from the windowing system (or via environment variables). That means the internal scale_factor in the Window is always 1 and changing it has no effect.

It might be desirable for users to customise this behavior, but this is not how Qt works: There is no support for per-widget scaling.

It might be possible to implement this on top of Qt by re-implementing QWidget::metric() and adjusting the DPR by the scale_factor. But that's not enough, there are places where Qt is used to perform measurements - such as text layout - where the scaling would have to be supplied manually. Similarly, the size constraints will also likely need to be adjusted.

Finally, there is no public API at the moment for changing the scale factor. There exists private API (through the access of window_handle() though.

tronical avatar Nov 23 '21 10:11 tronical

Currently, the Qt style is broken with scale factor when not using the Qt backend (eg, native style with winit backend) because the scale factor is applied twice.

ogoffart avatar Nov 29 '22 10:11 ogoffart

For a minute I thought this was just a Wayland issue. Now I know why this is the case.

wildwestrom avatar May 11 '24 11:05 wildwestrom