title: How to rotate a QPixmap without changing size
body: <p>How to rotate a QPixmap without changing size
  I use this code but when I rotate the image it change the size of the image.</p>
  
  <p>The header file </p>
  
  <pre><code>#ifndef CUSTOMDIAL_H
  #define CUSTOMDIAL_H
  #include &lt;QDial&gt;
  class CustomDial : public QDial
  {
  Q_OBJECT
  public:
  CustomDial(QWidget * parent = nullptr);
  private:
  virtual void paintEvent(QPaintEvent*) override;
  };
  #endif
  </code></pre>
  
  <p>the CPP file</p>
  
  <pre><code>#include "Customdial.h"
  #include &lt;QGraphicsPixmapItem&gt;
  #include &lt;QPainter&gt;
  #include &lt;QColor&gt;
  #include &lt;QPixmap&gt;
   CustomDial::CustomDial(QWidget* parent)
                      : QDial(parent)
   {
  // Default range
  QDial::setRange(0,100);
  }   
  void CustomDial::paintEvent(QPaintEvent*)
  {
  int a = QDial::sliderPosition();
  QPainter painter(this);
  //load pixmap
  QPixmap pix(":/img/img/knob.png");
  //rotate pixmap
  QMatrix rm;
          rm.rotate(a);
          pix = pix.transformed(rm);
  //draw pixmap
  painter.drawPixmap(QPointF(0,0),
                      pix.scaled(QDial::height(),
                      QDial::height(),
                      Qt::KeepAspectRatio),
                      pix.rect().adjusted(1, 1, -1000, -1000) );
  }
  </code></pre>
  
  <p>How to rotate a QPixmap without changing size I use this code but when I rotate the image it change the size of the image the header file</p>