title: QT paintEvent for a QWidget
body: <p>I've a class that inherits QPushButton widget. I want to have custom look of that button so i've overrided paintEvent method. All buttons that I want to paint are childs of QFrame object.</p>
  
  <p>And there I have a problem. I can't repaint those objects.</p>
  
  <p>My paintEvent function:</p>
  
  <pre><code>void Machine::paintEvent(QPaintEvent*) {
      QPainter painter(this);
      QRect geo = this-&gt;geometry();
  
      int x, y, width, height;
  
      x = geo.x()-10;
      y = geo.y()-10;
      width = geo.width()-3;
      height = geo.height()-5;
  
      painter.fillRect(x, y, width, height, QColor(220,220,220));
  
      painter.drawText(x+10, y+10, "Machine " + QString::number(id));
  }
  </code></pre>
  
  <p>When a widget is in top left corner of QFrame, desired effect is ok. But when I move button somewhere else, widget starts to disappear. On images you can see whats going on:</p>
  
  <p><img src="https://i.stack.imgur.com/IKSzp.png" alt="enter image description here"></p>
  
  <p>Button is just moved some px down-left. Why it works like this? QFrame which is a container for that button is big enough.</p>
  
  <p>Thanks in advance ;)</p>