QT设计师如何制作实际尺寸?

发布于 2025-02-06 23:13:29 字数 2915 浏览 1 评论 0原文

我对界面进行建模,并在编辑器窗口中大大且方便。但是,当我在Pycharm中运行结果程序时,我的程序和整个接口的窗口要小几倍。如何使这些尺寸重合? 我还可以指出,编辑器中的元素显然大于其像素尺寸。 我有Windows 10和4K显示器。 Windows界面在设置中超大。这是一个问题吗?

这是我的UI代码:

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>MainWindow</class>
 <widget class="QMainWindow" name="MainWindow">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>1074</width>
    <height>562</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>MainWindow</string>
  </property>
  <widget class="QWidget" name="centralwidget">
   <widget class="QPushButton" name="img_1">
    <property name="geometry">
     <rect>
      <x>20</x>
      <y>0</y>
      <width>512</width>
      <height>512</height>
     </rect>
    </property>
    <property name="text">
     <string/>
    </property>
    <property name="icon">
     <iconset>
      <normalon>../../Buty_frames/Leonardo_DiCaprio_1/GG0000_0.jpg</normalon>
     </iconset>
    </property>
    <property name="iconSize">
     <size>
      <width>512</width>
      <height>512</height>
     </size>
    </property>
   </widget>
   <widget class="QPushButton" name="img_2">
    <property name="geometry">
     <rect>
      <x>550</x>
      <y>0</y>
      <width>512</width>
      <height>512</height>
     </rect>
    </property>
    <property name="text">
     <string/>
    </property>
    <property name="icon">
     <iconset>
      <normalon>../../Buty_frames/Leonardo_DiCaprio_2/GG0042_0.jpg</normalon>
     </iconset>
    </property>
    <property name="iconSize">
     <size>
      <width>512</width>
      <height>512</height>
     </size>
    </property>
   </widget>
  </widget>
  <widget class="QMenuBar" name="menubar">
   <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
     <width>1074</width>
     <height>22</height>
    </rect>
   </property>
   <widget class="QMenu" name="menuAdd_hoto">
    <property name="title">
     <string>Add photo</string>
    </property>
   </widget>
   <addaction name="menuAdd_hoto"/>
  </widget>
  <widget class="QStatusBar" name="statusbar"/>
 </widget>
 <resources/>
 <connections/>
</ui>

“

I model the interface and make the elements in the editor window large and convenient. But when I run the resulting program already in pycharm, the window of my program and the whole interface are several times smaller. How can I make these sizes coincide?
I can also note that the elements in the editor are clearly larger than their pixel size.
I have windows 10 and 4k monitor. The windows interface is oversized in the settings. Can this be a problem?

This is my Ui code:

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>MainWindow</class>
 <widget class="QMainWindow" name="MainWindow">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>1074</width>
    <height>562</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>MainWindow</string>
  </property>
  <widget class="QWidget" name="centralwidget">
   <widget class="QPushButton" name="img_1">
    <property name="geometry">
     <rect>
      <x>20</x>
      <y>0</y>
      <width>512</width>
      <height>512</height>
     </rect>
    </property>
    <property name="text">
     <string/>
    </property>
    <property name="icon">
     <iconset>
      <normalon>../../Buty_frames/Leonardo_DiCaprio_1/GG0000_0.jpg</normalon>
     </iconset>
    </property>
    <property name="iconSize">
     <size>
      <width>512</width>
      <height>512</height>
     </size>
    </property>
   </widget>
   <widget class="QPushButton" name="img_2">
    <property name="geometry">
     <rect>
      <x>550</x>
      <y>0</y>
      <width>512</width>
      <height>512</height>
     </rect>
    </property>
    <property name="text">
     <string/>
    </property>
    <property name="icon">
     <iconset>
      <normalon>../../Buty_frames/Leonardo_DiCaprio_2/GG0042_0.jpg</normalon>
     </iconset>
    </property>
    <property name="iconSize">
     <size>
      <width>512</width>
      <height>512</height>
     </size>
    </property>
   </widget>
  </widget>
  <widget class="QMenuBar" name="menubar">
   <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
     <width>1074</width>
     <height>22</height>
    </rect>
   </property>
   <widget class="QMenu" name="menuAdd_hoto">
    <property name="title">
     <string>Add photo</string>
    </property>
   </widget>
   <addaction name="menuAdd_hoto"/>
  </widget>
  <widget class="QStatusBar" name="statusbar"/>
 </widget>
 <resources/>
 <connections/>
</ui>

Screenshot

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文