title: How to draw points and lines on widgets using PyQt
body: <p>I'm making an application, which should draw several points on widget and connect some of them with lines. I've made a form using QT Designer and I want to draw the points on frame for example. I've read that to draw on a widget its paintEvent() method should be reimplemented and I have a problem with it. My MainForm class has following code:</p>
  
  <pre><code>.........
  def paintEvent(self, QPaintEvent):
      paint = QtGui.QPainter()
      paint.begin(self)
      paint.setPen(QtCore.Qt.red)
      size = self.size()
      for i in range(100):
         x = random.randint(1, size.width()-1)
         y = random.randint(1, size.height()-1)
         paint.drawPoint(x, y)
      paint.end()
  ............
  </code></pre>
  
  <p>That method draws points on main window. How to make paintEvent() draw on exact frame of my form? And one more question: how make it only when I press some button because the code above redraws my window after any event.</p>
  
  <p>I use PyQt v4.10 and Python 3.3 if it's important.</p>
  
  <p>Thanks in advance for any help.</p>