QT设计师无法修改窗口大小,无法通过鼠标拖动窗口改变大小的解决方案

博主分享在使用pyside6创建界面时遇到窗口无法缩放的问题,通过探索UI文件发现缺少minimumSize属性。最终调整后,窗口缩放得以解决,揭示了设置最小尺寸对界面缩放的关键作用。

如题,我使用的是pyside6进行设计界面,通过添加布局实现了自动缩放的界面,但遇到了一个很诡异的现象,就是窗口无法缩小,在QT设计师界面,在geometry属性那里怎么修改,一点确定之后宽度和高度都是原来的值,无法修改窗口大小。然后生成界面运行之后也无法修改。

然后我将界面.ui文件用notepad++打开之后,大家有发现什么问题吗?

 <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>1024</width>
    <height>1024</height>
   </rect>
  </property>
  <property name="sizePolicy">
   <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
    <horstretch>0</horstretch>
    <verstretch>0</verstretch>
   </sizepolicy>
  </property>
  <property name="maximumSize">
   <size>
    <width>2000</width>
    <height>3000</height>
   </size>
  </property>

是的,里面少了minimumSize属性,于是我又添加了这个属性如下:

 <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>1024</width>
    <height>1024</height>
   </rect>
  </property>
  <property name="sizePolicy">
   <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
    <horstretch>0</horstretch>
    <verstretch>0</verstretch>
   </sizepolicy>
  </property>
  <property name="minimumSize">
   <size>
    <width>0</width>
    <height>0</height>
   </size>
  </property>
  <property name="maximumSize">
   <size>
    <width>2000</width>
    <height>3000</height>
   </size>
  </property>

结果还是不行,这时我有将minimunSize属性设置了一个初始值为100,如下

 <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>1024</width>
    <height>1024</height>
   </rect>
  </property>
  <property name="sizePolicy">
   <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
    <horstretch>0</horstretch>
    <verstretch>0</verstretch>
   </sizepolicy>
  </property>
  <property name="minimumSize">
   <size>
    <width>100</width>
    <height>100</height>
   </size>
  </property>
  <property name="maximumSize">
   <size>
    <width>2000</width>
    <height>3000</height>
   </size>
  </property>

然后保存之后,奇迹发生了,不管是在QT设计师还是运行之后都可以缩小窗口了。

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值