<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Pyside on Colin O'Flynn</title><link>https://colinoflynn.com/tag/pyside/</link><description>Recent content in Pyside on Colin O'Flynn</description><generator>Hugo</generator><language>en-ca</language><lastBuildDate>Sat, 18 Feb 2023 02:18:24 +0000</lastBuildDate><atom:link href="https://colinoflynn.com/tag/pyside/index.xml" rel="self" type="application/rss+xml"/><item><title>QTabWidget in PySide Automatically Resize</title><link>https://colinoflynn.com/2012/11/qtabwidget-in-pyside-automatically-resize/</link><pubDate>Thu, 08 Nov 2012 14:53:00 +0000</pubDate><guid>https://colinoflynn.com/2012/11/qtabwidget-in-pyside-automatically-resize/</guid><description>&lt;p&gt;When using PySide, a QTabWidget is handy. But the size of the QTabWidget is dictated by the largest item, even if it&amp;rsquo;s not visible.
Let&amp;rsquo;s assume self.tw is our tab widget. Then add this function:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;from PySide.QtCore import *
from PySide.QtGui import *

class MainWindow(QMainWindow):
 def curTabChange(self, index):
 for i in range(self.tw.count()):
 if i == index:
 self.tw.widget(i).setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
 else:
 self.tw.widget(i).setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)

 def myOtherFunction(self):
 etc etc etc
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;And in your initialization associate it with a tab change event:&lt;/p&gt;</description></item></channel></rss>