Qt Designer未正确配置对齐项目
我试图在Qt Designer中显示一些项目,但我无法这样做,因为尽管我正确地将它们放置在.ui中,但在编译和运行代码时,这些项目放错了位置: 您可以从上面的图像中注意到,我想要的是左侧:QStackedWidget内的四个项目与其他项目完全对齐,但我得到的是右侧的项目:QStackedWidget内的所有四个项目都未对齐 我试图尽可能多地操纵与保证金等相关的变量,但我无法理解为什么应用程序显示出与编程不同的东西。关于如何解决这个问题有什么建议吗Qt Designer未正确配置对齐项目,qt,user-interface,layout,alignment,qt-designer,Qt,User Interface,Layout,Alignment,Qt Designer,我试图在Qt Designer中显示一些项目,但我无法这样做,因为尽管我正确地将它们放置在.ui中,但在编译和运行代码时,这些项目放错了位置: 您可以从上面的图像中注意到,我想要的是左侧:QStackedWidget内的四个项目与其他项目完全对齐,但我得到的是右侧的项目:QStackedWidget内的所有四个项目都未对齐 我试图尽可能多地操纵与保证金等相关的变量,但我无法理解为什么应用程序显示出与编程不同的东西。关于如何解决这个问题有什么建议吗 更新 添加以下图像以帮助对以下给定答案进行评
更新 添加以下图像以帮助对以下给定答案进行评论:
更新 .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>306</width>
<height>229</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>306</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>306</width>
<height>229</height>
</size>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QGridLayout" name="gridLayout_4">
<item row="3" column="1">
<widget class="QPushButton" name="pbUpdate">
<property name="text">
<string>Update</string>
</property>
</widget>
</item>
<item row="3" column="0">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="2">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pbFullUpdate">
<property name="text">
<string>Full update</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbSingleFile">
<property name="text">
<string>Single file</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>89</width>
<height>17</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0" colspan="3">
<widget class="QStackedWidget" name="swInfo">
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="page">
<layout class="QGridLayout" name="gridLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Version ID:</string>
</property>
</widget>
</item>
<item row="0" column="2">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QPushButton" name="pbVersionIDIncrease1">
<property name="maximumSize">
<size>
<width>31</width>
<height>31</height>
</size>
</property>
<property name="text">
<string>^</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="pbVersionIDIncrease2">
<property name="maximumSize">
<size>
<width>31</width>
<height>31</height>
</size>
</property>
<property name="text">
<string>^</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pbVersionIDIncrease3">
<property name="maximumSize">
<size>
<width>31</width>
<height>31</height>
</size>
</property>
<property name="text">
<string>^</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="leID">
<property name="text">
<string>33.4550.1</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2">
<layout class="QGridLayout" name="gridLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="1">
<widget class="QLineEdit" name="leServerAddress">
<property name="minimumSize">
<size>
<width>186</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>186</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>Server path:</string>
</property>
<property name="buddy">
<cstring>leServerAddress</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lePathToSave">
<property name="minimumSize">
<size>
<width>186</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>186</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>/mmcblk0p2/</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Path to save:</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>Equipment IP:</string>
</property>
<property name="buddy">
<cstring>leEquipmentIP</cstring>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QLineEdit" name="leEquipmentIP">
<property name="minimumSize">
<size>
<width>186</width>
<height>33</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>186</width>
<height>33</height>
</size>
</property>
<property name="text">
<string>10.1.25.10</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="actionExit">
<property name="text">
<string>Exit</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<tabstops>
<tabstop>leEquipmentIP</tabstop>
<tabstop>pbUpdate</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
主窗口
0
0
306
229
306
0
306
229
主窗口
更新
Qt::水平
40
20
Qt::水平
40
20
全面更新
单个文件
Qt::水平
89
17
1.
0
0
0
版本ID:
31
31
^
31
31
^
31
31
^
33.4550.1
Qt::垂直
20
40
QLayout::SetDefaultConstraint
0
0
0
0
186
0
186
16777215
服务器路径:
leserver地址
186
0
186
16777215
/mmcblk0p2/
要保存的路径:
设备IP:
利基设备
186
33
186
33
10.1.25.10
出口
利基设备
pbUpdate
您是否尝试过使用表单布局(有两个类似表单的列)
更新:
我对上面和下面的部分使用了表单布局。中间有堆叠小部件。
线路输入的右侧正确对齐,左侧也正确对齐。我通过将堆叠小部件的所有边距设置为0来实现这一点,表单布局边距已经设置为0。
另外,我对整个表单使用了垂直布局,这对于三个布局的正确对齐是必要的。
问题是如何在标签的末尾和线的开头编辑之间对齐该零件。我认为如果不修改标签的最小/最大大小或左边的任何内容,这是不可能的
如果可能的话,在设计上做一些改变可能比在不同的布局之间(中间)对齐要好(我认为这是不可能的)
更新2:
好的,我把你的ui文件放在我的QtCreator测试项目中,结果很好-我没有你在更新的截图中显示的交叉线编辑问题。也许整个窗口都有一些剩余的大小调整-如果你调整窗口的大小会发生什么。无论我在做什么,我都不能触发相同的行为-行编辑始终正确对齐
剩下的问题是-你的QtCreator版本是什么,Qt版本是什么,操作系统是什么。
矿山为QtCreator 3.3.2 Qt 5.4.1 Kubuntu 14.04
<> P/< P> < P>中没有两个原因,因为它们不是同一个布局的一部分,所以中间的两个小部件应该与外部的排成一行。 如果底部标签中的文字变长,这一点应该更加明显: 因此,您的结论似乎是相反的:实际上编译版本是正确的,而Qt设计器版本需要进一步解释。但是如果不能测试真正的ui文件,很难说比这更多 更新: 如果将
main窗口
和leEquipmentIP
的最大/最小大小重置为默认值,则您可以更轻松地查看g