user2926577
user2926577

Reputation: 1827

Resizing Qt UI elements

I have a simple qt ui that contains

|- central widget
   |- label
   |- button

I would like to manually place and resize the label and button freely (using the mouse), and I just can't seem to be able to do that.

I can only resize the entire window, and the label/button stretch with it. I tried all combinations of size policies

Thanks!

<?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>326</width>
    <height>254</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>MainWindow</string>
  </property>
  <widget class="QWidget" name="centralWidget">
   <layout class="QVBoxLayout" name="verticalLayout">
    <item>
     <widget class="QLabel" name="label">
      <property name="text">
       <string>Bla</string>
      </property>
      <property name="alignment">
       <set>Qt::AlignCenter</set>
      </property>
     </widget>
    </item>
    <item>
     <widget class="QPushButton" name="startButton">
      <property name="text">
       <string>Start</string>
      </property>
     </widget>
    </item>
   </layout>
  </widget>
 </widget>
 <layoutdefault spacing="6" margin="11"/>
 <resources/>
 <connections/>
</ui>

Upvotes: 0

Views: 1281

Answers (2)

Marek R
Marek R

Reputation: 37697

Check this documentation. This should be helpful to utilize Qt Designer components. It is quite possible that you don't have to do lot of work. I never used this so my help ends here.

Upvotes: 1

VirtualSnake
VirtualSnake

Reputation: 83

try to remove <layout class="QVBoxLayout" name="verticalLayout"> and </layout> but if you are working under qt creator or qt designer, you can easily do this thing. You need to choose centralWidget and click to button Break Layout that placed under menu bar.

Upvotes: 1

Related Questions