【发布时间】:2014-12-12 14:47:43
【问题描述】:
附件是与我的问题有关的 QT 设计器示例。我的目标是让里面的任何内容(特别是 lineEdit)扩展到 QTabWidget 的最右边。
如果您注意到我在图片中选择了选项卡,并且显示当前没有布局(如其上的红色禁止吸烟符号所示)。 当我尝试使用选项卡上方的按钮向其添加布局时(对于水平、垂直、网格、表单等),无论我做什么都不会更改选项卡布局,但更改最顶层的小部件布局,而不是,这是我不想要的,因为这使 QTabWidget 能够承受任何大小的窗口。
我尝试为选项卡中的元素提供水平和垂直布局,认为这可能有效,但正如我的下一张附加图片所示,它也不起作用。我的预感是因为选项卡没有布局,里面的任何布局都不会被尊重。
感谢任何帮助。我已经花了好几个小时,但我这辈子都想不通......!
以下是 UI XML:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>xMarket</class>
<widget class="QWidget" name="xMarket">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>737</width>
<height>421</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QTabWidget" name="xMarketTabWidget">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Tab 1</string>
</attribute>
<widget class="QLineEdit" name="lineEdit">
<property name="geometry">
<rect>
<x>240</x>
<y>30</y>
<width>113</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>150</x>
<y>30</y>
<width>59</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Search:</string>
</property>
</widget>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Tab 2</string>
</attribute>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
【问题讨论】:
标签: c++ xml user-interface qt5 qt-designer