title: Qt QPainter error when rotating an ellipse using horizontalSlider
body: <p>I have to create a simple box which rotates an ellipse and some text depending upon value from horizontalSlider/spinBox. The widget has to be resizable, And size of the ellipse has to change depending upon that.</p>
  
  <p>For now only the ellipse is being painted. The text painting will be added if this works. The problem is that if the window after resize exceeds the original window size, the painting is weird.</p>
  
  <p>window.h:</p>
  
  <pre><code>#ifndef WINDOW_H
  #define WINDOW_H
  
  #include &lt;QtGui&gt;
  #include "ui_form.h"
  
  class Window : public QWidget, private Ui::Form
  {
      Q_OBJECT
  
  public:
      Window(QWidget *parent = 0);
  
  public slots:
      void rotateEllip(int angle);
      void rotateText(int angle);
  
  protected:
      void paintEvent(QPaintEvent *event);
  };
  
  #endif // WINDOW_H
  </code></pre>
  
  <p>window.cpp:</p>
  
  <pre><code>#include "window.h"
  
  qreal textAngle = 0.0;
  
  qreal ellipAngle = 0.0;
  
  Window::Window(QWidget *parent) : QWidget(parent)
  {
      setupUi(this);
  
      connect(spinBox_ellipse,SIGNAL(valueChanged(int)),this,SLOT(rotateEllip(int)));
      connect(horizontalSlider_ellipse,SIGNAL(valueChanged(int)),this,SLOT(rotateEllip(int)));
      connect(spinBox_text,SIGNAL(valueChanged(int)),this,SLOT(rotateText(int)));
      connect(horizontalSlider_text,SIGNAL(valueChanged(int)),this,SLOT(rotateText(int)));
  }
  
  void Window::rotateEllip(int angle)
  {
      ellipAngle = (qreal) angle;
      Window::Window(this);
  }
  
  void Window::rotateText(int angle) 
  {
      textAngle = (qreal) angle;
      Window::Window(this);
  }
  
  void Window::paintEvent(QPaintEvent *event) 
  {
      QPen pen(Qt::black,2,Qt::SolidLine);
      QPoint center(0,0);
  
      QPainter painter(this);
  
      painter.setRenderHint(QPainter::Antialiasing);
  /*    Drawing ellipse*/
  
  
      painter.eraseRect(10,10,frame_ellipse-&gt;width(),frame_ellipse-&gt;height());
      painter.translate(frame_ellipse-&gt;width()/2+10,frame_ellipse-&gt;height()/2+10);
      painter.rotate(ellipAngle);
      if (frame_ellipse-&gt;width() &gt; frame_ellipse-&gt;height()) painter.drawEllipse(center,(frame_ellipse-&gt;height()/4)-5,(frame_ellipse-&gt;height()/2)-10);
      else if (frame_ellipse-&gt;width() &lt;= frame_ellipse-&gt;height() ) painter.drawEllipse(center,(frame_ellipse-&gt;width()/2)-10,(frame_ellipse-&gt;width()/4)-5);
      painter.rotate(-ellipAngle);
      painter.translate(-frame_ellipse-&gt;width()/2+10,-frame_ellipse-&gt;height()/2+10);
  }
  </code></pre>
  
  <p>main.cpp is normal window.show() calling.</p>