Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/134.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ QTabWidget内容未扩展_C++_Xml_User Interface_Qt5_Qt Designer - Fatal编程技术网

C++ QTabWidget内容未扩展

C++ QTabWidget内容未扩展,c++,xml,user-interface,qt5,qt-designer,C++,Xml,User Interface,Qt5,Qt Designer,附件是我的问题QT设计器的一个例子。我的目标是让里面的任何内容(特别是lineEdit)扩展到QTabWidget的最右边 如果您注意到我在图片中选择了选项卡,它表示当前没有布局(如图中红色禁止吸烟符号所示)当我尝试使用选项卡上方的按钮向其添加布局时(对于水平、垂直、网格、表格等…),无论我做什么,都不会更改选项卡布局,而是更改顶级小部件布局,这是我不想要的,因为这使QTabWidget能够处理任何大小的窗口 我尝试为选项卡中的元素提供水平和垂直布局,认为这可能会起作用,但正如我的下一幅附加图像

附件是我的问题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>

X市场
0
0
737
421
0
0
形式
Qt::LeftToRight
Qt::LeftToRight
表1
240
30
113
21
150
30
59
16
搜索:
表2

要设置选项卡上的布局,首先需要选择其父选项卡小部件

您可以通过在对象检查器中按名称选择它(即,在您的示例中单击
xMarketTabWidget
),或者只需单击其选项卡栏中的适当选项卡即可。父选项卡小部件周围必须有一个选择矩形,然后才能在其中一个选项卡上设置布局


完成此操作后,可以单击设计器工具栏上的“水平布局”或“网格布局”按钮,为选项卡设置适当的布局。但请注意,选项卡必须至少有一个子小部件,然后才能在其上设置布局-空选项卡的布局按钮都将被禁用。

要在选项卡上设置布局,首先需要选择其父选项卡小部件

您可以通过在对象检查器中按名称选择它(即,在您的示例中单击
xMarketTabWidget
),或者只需单击其选项卡栏中的适当选项卡即可。父选项卡小部件周围必须有一个选择矩形,然后才能在其中一个选项卡上设置布局


完成此操作后,可以单击设计器工具栏上的“水平布局”或“网格布局”按钮,为选项卡设置适当的布局。但请注意,选项卡必须至少有一个子小部件,才能在其上设置布局-对于空选项卡,布局按钮都将被禁用。

这是有效的,我发誓我以前尝试过,但这样做确实允许我正确设置布局。非常感谢。这很管用,我发誓我以前试过,但这样做确实让我能够正确设置布局。非常感谢。