<pre class="de1">Hi all,<br><br> In the below program the style sheet properties isn't working even after it's set. Can you please where i went wrong????<br> <br>from PyQt4 import QtCore, QtGui<br>import sys<br>
<br>class Ui_TabWidget<span class="br0">(</span>object<span class="br0">)</span><span class="sy0">:</span><br> def setupUi<span class="br0">(</span>self, TabWidget<span class="br0">)</span><span class="sy0">:</span><br>
TabWidget.<span class="me1">setObjectName</span><span class="br0">(</span><span class="st0">"TabWidget"</span><span class="br0">)</span><br> TabWidget.<span class="me1">resize</span><span class="br0">(</span><span class="nu0">400</span>, <span class="nu0">300</span><span class="br0">)</span><br>
<br> self.<span class="me1">tabBar</span><span class="sy0">=</span>QtGui.<a href="http://doc.trolltech.com/latest/QTabBar.html"><span class="kw6">QTabBar</span></a><span class="br0">(</span>TabWidget<span class="br0">)</span><br>
<br> self.<span class="me1">tabBar</span>.<span class="me1">setStyleSheet</span><span class="br0">(</span><span class="st0">"QTabBar{left-margin:20;right-margin:20;}"</span><span class="br0">)</span><br>
<br> self.<span class="me1">tabBar</span>.<span class="me1">addTab</span><span class="br0">(</span><span class="st0">"Tab1"</span><span class="br0">)</span><br> self.<span class="me1">tabBar</span>.<span class="me1">setTabText</span><span class="br0">(</span><span class="nu0">0</span>,<span class="st0">"hello"</span><span class="br0">)</span><br>
<br> self.<span class="me1">tabBar</span>.<span class="me1">addTab</span><span class="br0">(</span><span class="st0">"Tab2"</span><span class="br0">)</span><br> self.<span class="me1">tabBar</span>.<span class="me1">setTabText</span><span class="br0">(</span><span class="nu0">1</span>,<span class="st0">"hai"</span><span class="br0">)</span><br>
<br> TabWidget.<span class="me1">setTabBar</span><span class="br0">(</span>self.<span class="me1">tabBar</span><span class="br0">)</span><br> <br> self.<span class="me1">retranslateUi</span><span class="br0">(</span>TabWidget<span class="br0">)</span><br>
<br> QtCore.<a href="http://doc.trolltech.com/latest/QMetaObject.html"><span class="kw6">QMetaObject</span></a>.<span class="me1">connectSlotsByName</span><span class="br0">(</span>TabWidget<span class="br0">)</span><br>
<br> def retranslateUi<span class="br0">(</span>self, TabWidget<span class="br0">)</span><span class="sy0">:</span><br> TabWidget.<span class="me1">setWindowTitle</span><span class="br0">(</span>QtGui.<a href="http://doc.trolltech.com/latest/QApplication.html"><span class="kw6">QApplication</span></a>.<span class="me1">translate</span><span class="br0">(</span><span class="st0">"TabWidget"</span>, <span class="st0">"TabWidget"</span>, None, QtGui.<a href="http://doc.trolltech.com/latest/QApplication.html"><span class="kw6">QApplication</span></a>.<span class="me1">UnicodeUTF8</span><span class="br0">)</span><span class="br0">)</span><br>
<br> <br>app <span class="sy0">=</span> QtGui.<a href="http://doc.trolltech.com/latest/QApplication.html"><span class="kw6">QApplication</span></a><span class="br0">(</span>sys.<span class="me1">argv</span><span class="br0">)</span><br>
<br>TabWidget <span class="sy0">=</span> QtGui.<a href="http://doc.trolltech.com/latest/QTabWidget.html"><span class="kw6">QTabWidget</span></a><span class="br0">(</span><span class="br0">)</span><br>ui <span class="sy0">=</span> Ui_TabWidget<span class="br0">(</span><span class="br0">)</span><br>
ui.<span class="me1">setupUi</span><span class="br0">(</span>TabWidget<span class="br0">)</span><br>TabWidget.<span class="me1">show</span><span class="br0">(</span><span class="br0">)</span><br>sys.<span class="kw3">exit</span><span class="br0">(</span>app.<span class="me1">exec_</span><span class="br0">(</span><span class="br0">)</span><span class="br0">)</span></pre>