#๐ How to set a fixed aspect ration in PyQt
24 messages ยท Page 1 of 1 (latest)
@candid basin
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
widgets resizing when the UI around it resizes is a result of the widget's size policy
you can use setFixedSize if you want a fixed size policy and for the widget to no longer resize
label.setFixedSize(32, 32)
yeah I knew that but it has to change
is there any way to keep the height and width the same?
you'd have to override the resizeEvent of the widget
Can you show what it looks like in the UI?
What exactly do you want to happen?
Typically icons don't resize with the window
sure
but what someone is using a 4k monitor and another person is using a 1080p monitor
if I set the fixed size for the 4k monitor
the icon would be massive for the 1080p monitor
Then you have different size profiles based on what their display DPI is
if resolution is so and so, use larger icons
ok,
also is it bad practice to change the icon size with the window?
generally yes. I can't think of UIs that do that
alright then I will implement the DPI system instead
@raw bluff ty, you are a legend (:
!solved
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.