Jos*_*han 0 c++ xml user-interface qt-designer qt5
附件是我的问题的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>
Run Code Online (Sandbox Code Playgroud)
要在选项卡上设置布局,首先需要选择其父选项卡窗口小部件.
您可以通过在对象检查器中按名称选择它(即xMarketTabWidget在示例中单击),或者只需单击其选项卡栏中的相应选项卡即可.父选项卡窗口小部件必须在其周围有一个选择矩形,然后才能在其中一个选项卡上设置布局.
完成后,可以单击Designer工具栏上的"水平布局"或"网格布局"按钮,为选项卡设置适当的布局.但请注意,选项卡必须至少有一个子窗口小部件才能在其上设置布局 - 布局按钮将全部禁用为空选项卡.