<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
<font style="" face="Courier New">Below is a sample program that demonstrates a problem with the updating of a Tab's size when setTabsClosable(false) is dynamically set.<br>Run the program as is and add some tabs, and then remove some with either the close box or the 'Remove' button.  When the last tab is shown, you'll see that it remains wide enough to contain the 'X' close button, even though it is not drawn.<br><br>Use the 'Toggle Fix" button and add and remove tabs again to see the way the tabs should be redrawn when the 'X' box is removed on the last tab.<br><br>I think this is a problem with QT itself. I've tested this running on Qt 4.5.x and 4.6.x<br><br>I've tried a QTimer to force an update and that doesn't seem to work in either Python or C++<br><br>Has this been fixed in a newer version of Qt, e.g. 4.7.x?<br><br>-Nate<br><br>---- begin test.py ----<br><br>#!/bin/env python<br>import sys<br><br>from PyQt4 import QtCore<br>from PyQt4 import QtGui<br><br>MIN_EDITORS = 1<br><br>class MainWindow(QtGui.QMainWindow):<br>    def __init__(self, *args):<br>        super(MainWindow, self).__init__(*args)<br>        self.widget = QtGui.QWidget(self)<br>        self.layout = QtGui.QVBoxLayout()<br>        self.widget.setLayout(self.layout)<br>        self.btnAdd = QtGui.QPushButton("Add")<br>        self.btnRem = QtGui.QPushButton("Remove")<br>        self.btnFix = QtGui.QPushButton("Toggle Fix")<br>        self.connect(self.btnAdd, QtCore.SIGNAL("clicked()"), self.addEditor)<br>        self.connect(self.btnRem, QtCore.SIGNAL("clicked()"), self.remEditor)<br>        self.connect(self.btnFix, QtCore.SIGNAL("clicked()"), self.toggleFix)<br>        self.tw = QtGui.QTabWidget(self)<br>        self.connect(self.tw, QtCore.SIGNAL("tabCloseRequested(int)"), self.remEditor)<br>        self.setCentralWidget(self.widget)<br>        self.layout.addWidget(self.tw)<br>        self.layout.addWidget(self.btnAdd)<br>        self.layout.addWidget(self.btnRem)<br>        self.layout.addWidget(self.btnFix)<br>        self.fix_tabs = False<br>        self.addEditor()<br>        <br>    def addEditor(self):<br>        widget = QtGui.QWidget()<br>        textedit = QtGui.QTextEdit(widget)<br>        layout = QtGui.QVBoxLayout()<br>        layout.addWidget(textedit)<br>        widget.setLayout(layout)<br>        self.tw.addTab(widget, "blah")<br>        self.tw.setTabsClosable(self.tw.count() > MIN_EDITORS);<br>        <br>    def remEditor(self, index=-1):<br>        if (self.tw.count() <= MIN_EDITORS):<br>            return<br>        if (index < 0):<br>            index = self.tw.currentIndex()<br>        self.tw.removeTab(index)<br>        self.tw.setTabsClosable(self.tw.count() > MIN_EDITORS);<br>        if self.fix_tabs:<br>            self.fixTabs()<br>    <br>    def fixTabs(self):<br>        tabBar = self.tw.tabBar()<br>        tabBar.setTabText(0, tabBar.tabText(0))<br><br>    def toggleFix(self):<br>        self.fix_tabs = not self.fix_tabs<br><br>if __name__ == '__main__':<br>    app = QtGui.QApplication(sys.argv)<br>    mw = MainWindow()<br>    mw.show()<br>    sys.exit(app.exec_())<br><br># ---- end test.py ----<br><br></font><font style="" face="Courier New"><br></font>                                           </body>
</html>