How to create a sketch area in a ui window

82 Views Asked by At

My requirement.

enter image description here

What I tried in Qt 5.15?

enter image description here

My Question: How to create sketch area in the layout window so that there is sketching space and space for my sketching features? Can anyone help with this? I hope my question is clear.

2

There are 2 best solutions below

0
ΦXocę 웃 Пepeúpa ツ On

you need to play with the layout properties... specifically the layoutstretch

if you set that to 1,5 the left widget is taking space in a ration 1:5 to the right widget...

0
Parisa.H.R On

1.First of all, I put all your TabWidget in centralwidget with 2 tabs Tab1 and Tab2 like this :

enter image description here

  1. I go to this and change the maximum size to 200 this is l1.

enter image description here

3.set GridLayout For centralwidget and add one widget near Tabwidget.

enter image description here

you can set maximum width of widget to 1000.as l1*5.

4.put pushbuttons in tab1 and I set Vertical layout for Tab1 .

enter image description here

this UI code you can copy+past it in your UI file and use it.

<?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>537</width>
    <height>357</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>MainWindow</string>
  </property>
  <widget class="QWidget" name="centralwidget">
   <layout class="QGridLayout" name="gridLayout_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>
    <property name="spacing">
     <number>0</number>
    </property>
    <item row="1" column="1">
     <widget class="QTabWidget" name="tabWidget">
      <property name="minimumSize">
       <size>
        <width>200</width>
        <height>0</height>
       </size>
      </property>
      <property name="maximumSize">
       <size>
        <width>200</width>
        <height>16777215</height>
       </size>
      </property>
      <widget class="QWidget" name="tab">
       <attribute name="title">
        <string>Tab 1</string>
       </attribute>
       <layout class="QVBoxLayout" name="verticalLayout">
        <item>
         <widget class="QPushButton" name="pushButton">
          <property name="text">
           <string>PushButton 1</string>
          </property>
         </widget>
        </item>
        <item>
         <widget class="QPushButton" name="pushButton_2">
          <property name="text">
           <string>PushButton 2</string>
          </property>
         </widget>
        </item>
        <item>
         <widget class="QPushButton" name="pushButton_3">
          <property name="text">
           <string>PushButton 3</string>
          </property>
         </widget>
        </item>
        <item>
         <widget class="QPushButton" name="pushButton_4">
          <property name="text">
           <string>PushButton 4</string>
          </property>
         </widget>
        </item>
        <item>
         <widget class="QPushButton" name="pushButton_5">
          <property name="text">
           <string>PushButton 5</string>
          </property>
         </widget>
        </item>
        <item>
         <widget class="QPushButton" name="pushButton_6">
          <property name="text">
           <string>PushButton 6</string>
          </property>
         </widget>
        </item>
       </layout>
      </widget>
      <widget class="QWidget" name="tab_2">
       <attribute name="title">
        <string>Tab 2</string>
       </attribute>
      </widget>
     </widget>
    </item>
    <item row="1" column="2">
     <widget class="QWidget" name="widget" native="true">
      <property name="minimumSize">
       <size>
        <width>1000</width>
        <height>0</height>
       </size>
      </property>
      <property name="maximumSize">
       <size>
        <width>1000</width>
        <height>16777215</height>
       </size>
      </property>
     </widget>
    </item>
   </layout>
  </widget>
  <widget class="QMenuBar" name="menubar">
   <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
     <width>537</width>
     <height>21</height>
    </rect>
   </property>
   <widget class="QMenu" name="menuFile">
    <property name="title">
     <string>File</string>
    </property>
   </widget>
   <widget class="QMenu" name="menuEdit">
    <property name="title">
     <string>Edit </string>
    </property>
   </widget>
   <widget class="QMenu" name="menuAbout">
    <property name="title">
     <string>About</string>
    </property>
   </widget>
   <addaction name="menuFile"/>
   <addaction name="menuEdit"/>
   <addaction name="menuAbout"/>
  </widget>
  <widget class="QStatusBar" name="statusbar"/>
 </widget>
 <resources/>
 <connections/>
</ui>