#๐Ÿ”’ How to set a fixed aspect ration in PyQt

24 messages ยท Page 1 of 1 (latest)

candid basin
#

Hey, for some reason I cant find such an obvious question online
I have some Qlabels in a QVBoxLayout, and these have 1:1 images set to them, how can I prevent the aspect ratio from changing?
https://paste.pythondiscord.com/IPCQ
It's name plat_icons and I have set a minimum of 16, 16 and a maximum of 32, 32 for it

bleak juncoBOT
#

@candid basin

Python help channel opened

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.

raw bluff
#

you can use setFixedSize if you want a fixed size policy and for the widget to no longer resize

#

label.setFixedSize(32, 32)

candid basin
#

yeah I knew that but it has to change

candid basin
raw bluff
#

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

candid basin
#

sure

candid basin
#

if I set the fixed size for the 4k monitor

#

the icon would be massive for the 1080p monitor

raw bluff
#

Then you have different size profiles based on what their display DPI is

#

if resolution is so and so, use larger icons

candid basin
raw bluff
#

generally yes. I can't think of UIs that do that

candid basin
#

alright then I will implement the DPI system instead

#

@raw bluff ty, you are a legend (:

#

!solved

bleak juncoBOT
#
Python help channel closed with !close

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.