title: Python PyQt4 Qpainter active message
body: <p>I was trying to display my <code>QTabWidget</code> text horizontally with the <code>Tabposition</code> set to 2 (left side). After searching around, i found the following code from <a href="https://stackoverflow.com/questions/3607709/how-to-change-text-alignment-in-qtabwidget">this link</a>.</p>
  
  <pre><code>class FingerTabWidget(QtGui.QTabBar):
      def __init__(self, *args, **kwargs):
          self.tabSize = QtCore.QSize(kwargs.pop('width'), kwargs.pop('height'))
          super(FingerTabWidget, self).__init__(*args, **kwargs)
  
      def paintEvent(self, event):
          painter = QtGui.QStylePainter(self)
          option = QtGui.QStyleOptionTab()
  
          painter.begin(self)
          for index in range(self.count()):
              self.initStyleOption(option, index)
              tabRect = self.tabRect(index)
              tabRect.moveLeft(10)
              painter.drawControl(QtGui.QStyle.CE_TabBarTabShape, option)
              painter.drawText(tabRect, QtCore.Qt.AlignVCenter | QtCore.Qt.TextDontClip, self.tabText(index));
          painter.end()
      def tabSizeHint(self,index):
          return self.tabSize
  </code></pre>
  
  <p>I managed to apply this code by just simply using this</p>
  
  <pre><code>Tab = QtGui.QTabWidget()
  Tab.setTabBar(FingerTabWidget(width=260,height=28))
  </code></pre>
  
  <p>Everything looks exactly like i expected and working fine but i am keep getting this error message everytime i mouse over on one of the tab. </p>
  
  <pre><code>QPainter::begin: Painter already active
  </code></pre>
  
  <p>Even though it does not affect the functionality of my program, i would like to know what is causing this error message. A simple explanation will do.</p>