title: Activating QPainter upon hover event
body: <p>Here is some code that illustrates my problem:</p>
  
  <pre><code>import sys
  from PyQt4 import QtGui, QtCore
  
  
  class CustomButton(QtGui.QAbstractButton):
      def __init__(self, *__args):
          super().__init__(*__args)
          self.setFixedSize(190, 50)
          self.installEventFilter(self)
  
      def paintEvent(self, event):
          painter = QtGui.QPainter(self)
          painter.setBrush(QtGui.QColor(136, 212, 78))
          painter.setPen(QtCore.Qt.NoPen)
          painter.drawRect(QtCore.QRect(0, 0, 100, 48))
  
      def eventFilter(self, object, event):
          if event.type() == QtCore.QEvent.HoverMove:
              painter = QtGui.QPainter(self)
              painter.begin(self)
              painter.drawRect(QtCore.QRect(0, 0, 100, 48))
              painter.end()
              return True
          return False
  
  app = QtGui.QApplication(sys.argv)
  window = QtGui.QWidget()
  layout = QtGui.QGridLayout(window)
  
  button = CustomButton()
  layout.addWidget(button, 0, 0)
  
  window.show()
  sys.exit(app.exec_())
  </code></pre>
  
  <p>The goal is to make a button using <code>QPainter</code> that can be modified when the <code>HoverMove</code> event is detected. However, I get the following errors upon hovering:</p>
  
  <pre><code>QPainter::begin: Paint device returned engine == 0, type: 1
  QPainter::begin: Paint device returned engine == 0, type: 1
  QPainter::drawRects: Painter not active
  QPainter::end: Painter not active, aborted
  </code></pre>
  
  <p>From what I've understood from the docs (<a href="http://pyqt.sourceforge.net/Docs/PyQt4/qpainter.html#details" rel="nofollow noreferrer">here</a>) I can use <code>.begin()</code> to activate the <code>QPainter</code>; however as the error message shows this isn't the case and the second rectangle does not get drawn. How should I use <code>QPainter</code> to achieve the desired output ?</p>