title: How to change text alignment in QTabWidget?
body: <p>I cannot find a way to set the text alignment in a QTabWidget. </p>
  
  <p>After I've created an instance of this widget, I've set its <em>tabPosition</em> property to West, but I wish it showed text/label horizontally.
  I've given a look to the Qt's <a href="https://doc.qt.io/qt-4.8/stylesheet-reference.html" rel="nofollow noreferrer">stylesheets</a>, but as you can see, the <em>text-align</em> property can only be set on QPushButton and QProgressBar.</p>
  
  <p>I already searched on the web, but I just found a <a href="https://bugreports.qt.io/browse/QTBUG-1286" rel="nofollow noreferrer">bugreport</a>, a <a href="http://www.qtcentre.org/threads/33245-QTabWidget-West-and-horizontal-text" rel="nofollow noreferrer">non-answered question</a>, and finally <a href="http://www.qtcentre.org/threads/25905-QTabWidget-West?p=123636#post123636" rel="nofollow noreferrer">a user</a> that suggests to re-implement the paint() method. 
  Maybe I'd solve, but I'm using Python (PyQt or PySide) and I don't know how to do it.</p>
  
  <p>Can you help me?</p>
  
  <p>EDIT: 
  thanks to Teukamm, I wrote a bit of code:</p>
  
  <pre><code>from PyQt4 import QtGui, QtCore
  
  class HorizontalTabWidget(QtGui.QTabBar):
      def paintEvent(self, event):
          for index in range(self.count()):
              painter = QtGui.QPainter()
              painter.begin(self)
              painter.setPen(QtCore.Qt.blue);
              painter.setFont(QtGui.QFont("Arial", 10));
              tabRect = self.tabRect(index)
              painter.drawText(tabRect, QtCore.Qt.AlignVCenter | QtCore.Qt.TextDontClip, self.tabText(index));
              painter.end()
  
       def sizeHint(self):
           return QtCore.QSize(60, 130)
  
  import sys
  app = QtGui.QApplication(sys.argv)
  tabs = QtGui.QTabWidget()
  tabs.setTabBar(HorizontalTabWidget())
  widget1 =  QtGui.QWidget()
  widget2 =  QtGui.QWidget()
  tabs.addTab(widget1, "Widget1")
  tabs.addTab(widget2, "Widget2")
  tabs.setTabPosition(2)
  tabs.show()
  sys.exit(app.exec_())
  </code></pre>
  
  <p>And finally I've my text aligned as I expected, but I've a little (big?) problem: when you click on the right side of every tab button, it doesn't send the <a href="https://doc.qt.io/qt-4.8/qtabbar.html#currentIndex-prop" rel="nofollow noreferrer"><em>currentChanged</em> SIGNAL</a>. I've also tried to expand the width of every tabRect, in paintEvent, but it doesn't work. What should I change? </p>
  
  <p>Thank you :)</p>
  
  <p>BTW: you could not inherit from QTabWidget, but from QTabBar ;)</p>
  
  <p>EDIT:</p>
  
  <p>Solved! Just changed the method <strong>sizeHint</strong> in <strong>tabSizeHint</strong> and it works well :)</p>