简体   繁体   中英

Pyqt5 multiple sizes tableWidget

在此处输入图像描述

i have created a window in qtDesigner where i have two frames, in frame1 there are two tableWidgets and frame2 i have one tableWidget. all tableWidget have same heights like 50-50%. i want to set the height of the frame1 or tableWidget1 &2 to 30% and frame2 will be 70% as shown in the image. may be it is easy to do or definitely have the functionality, but i am not able to find and do this.

It is recommended that you provide an MRE, for example in your case it would be great if you provide the.ui, since you have not provided it then in my answer I will have to create it but it will not necessarily be the same as your samples.


As the QFrame are the containers of the QTableWidget then these define the height of them, and the size of them can be set through a QVBoxLayout they are a proportional stretching factor:

在此处输入图像描述

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>Form</class>
 <widget class="QWidget" name="Form">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>400</width>
    <height>300</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>Form</string>
  </property>
  <layout class="QVBoxLayout" name="verticalLayout" stretch="3,7">
   <item>
    <widget class="QFrame" name="frame">
     <property name="frameShape">
      <enum>QFrame::StyledPanel</enum>
     </property>
     <property name="frameShadow">
      <enum>QFrame::Raised</enum>
     </property>
     <layout class="QHBoxLayout" name="horizontalLayout">
      <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>
       <widget class="QTableWidget" name="tableWidget"/>
      </item>
      <item>
       <widget class="QTableWidget" name="tableWidget_2"/>
      </item>
     </layout>
    </widget>
   </item>
   <item>
    <widget class="QFrame" name="frame_2">
     <property name="frameShape">
      <enum>QFrame::StyledPanel</enum>
     </property>
     <property name="frameShadow">
      <enum>QFrame::Raised</enum>
     </property>
     <layout class="QVBoxLayout" name="verticalLayout_2">
      <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>
       <widget class="QTableWidget" name="tableWidget_3"/>
      </item>
     </layout>
    </widget>
   </item>
  </layout>
 </widget>
 <resources/>
 <connections/>
</ui>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM