Issue
here's a thing I'm trying to solve in QT Creator. I want to make contents of the tab widget as well as the tab widget itself to be stretchable depending on the screen size. So far I've been looking for solutions on StackOverflow but couldn't find any.
A small example:
As suggested in other answers I organized all contents to be in the Grid layout which has these properties.
In fact I even added the same Expanding
value to all objects in a list. But in spite of that I'm still getting a fixed tab widget when I open it in a full screen size.
Any suggestions how to make the tab widget to fill all the surrounding space? Thanks in advance!
UPD 1: Sharing also my .ui https://gist.github.com/Ren22/41ca0dc0333a360775aec530d6f38a62
Solution
The size policy only works if the widget geometry is handled by a layout, so a solution is to set the QTabWidget as centralwidget to do it right click on an area that is outside the QTabWidget but inside the QMainWindow, then click on the icon or icon at the top of Qt Designer generating the following:
<?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>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTabWidget" name="tabWidget">
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Tab 1</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QListWidget" name="listWidget"/>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>PushButton</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Tab 2</string>
</attribute>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>30</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>
Answered By - eyllanesc
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.