@Pl45m4 said in Window cannot shrink after expanding:
In the first place, why you set the image on every resizeEvent?
This was the only way I could find to make the label's contents be resized to fit the window. The images I'm displaying are quite hi-res TIFFs, and at native resolution they can't fit on my 1080p monitor. I assume there's a better way to do this, but I couldn't find one.
Horizontally? Vertically? Or both?
Both. Here's a video of the behavior:
https://youtu.be/pe7nOlxXKcA
And here's the configuration of another window exhibiting the same behavior
[image: 0ba88c8a-50ae-4f23-afdb-4d1e08850cc6.png]
[image: 840db8d5-288a-4889-816a-ffe3ff9438e8.png]
This is the full form file of that window, in case that's helpful:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PointSelector</class>
<widget class="QWidget" name="PointSelector">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>643</width>
<height>528</height>
</rect>
</property>
<property name="windowTitle">
<string>Point Selector</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="imageDisplay">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>No File</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter|Qt::AlignHCenter|Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Left Click on head | Right Click on tail</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="confirmButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>175</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Confirm</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>