title: drawing a point over an image on QLabel
body: <p>I displayed a picture on QLabel and wanted to take coordinates and paint a point on image on mouse click event. I am able to get coordinates but painter is painting point below my image on label, i want it above my image.</p>
  
  <p>My code is :</p>
  
  <p>main.cpp</p>
  
  <pre><code>#include "imageviewer.h"
  #include &lt;QApplication&gt;
  int main(int argc, char *argv[])
  {
      QApplication a(argc, argv);
      imageviewer w;
      w.showMaximized();
  
      return a.exec();
  }
  </code></pre>
  
  <p>imageviewer.h</p>
  
  <pre><code>#include &lt;QPushButton&gt;
  
  class imageviewer : public QLabel
  {
      Q_OBJECT
  
  public:
      explicit imageviewer(QWidget *parent = 0);
  
  private slots:
  
      void mousePressEvent(QMouseEvent * e);
      void paintEvent(QPaintEvent * e);
  
  private:
  
      QLabel *label1 ;
      int mFirstX;
      int mFirstY;
      bool mFirstClick;
      bool mpaintflag;
  
  };
  
  #endif
  </code></pre>
  
  <p>imageviewer.cpp</p>
  
  <pre><code>#include &lt;QtGui&gt;
  #include &lt;QHBoxLayout&gt;
  #include &lt;QVBoxLayout&gt;
  #include "imageviewer.h"
  #include &lt;QDebug&gt;
  
  imageviewer::imageviewer(QWidget *parent)
      : QLabel(parent)
  {
  
  
      label1 = new QLabel;
      label1-&gt;setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
      QPixmap pm1("/home/nishu/Pictures/img_0002.jpg");
      label1-&gt;setPixmap(pm1);
      label1-&gt;adjustSize();
      label1-&gt;setScaledContents(true);
  
      QHBoxLayout *hlayout1 = new QHBoxLayout;
      hlayout1-&gt;addWidget(label1);
  
      setLayout(hlayout1);
  }
  
  void imageviewer :: mousePressEvent(QMouseEvent *e)
  {
      mFirstX=0;
      mFirstY=0;
      mFirstClick=true;
      mpaintflag=false;
  
      if(e-&gt;button() == Qt::LeftButton)
              {
                  //store 1st point
                  if(mFirstClick)
                  {
                      mFirstX = e-&gt;x();
                      mFirstY = e-&gt;y();
                      mFirstClick = false;
                      mpaintflag = true;
                      qDebug() &lt;&lt; "First image's coordinates" &lt;&lt; mFirstX &lt;&lt; "," &lt;&lt; mFirstY ;
                      update();
  
                  }
  
              }
  }
  
  void imageviewer :: paintEvent(QPaintEvent * e)
  {
  
      QLabel::paintEvent(e);
  
      if(mpaintflag)
      {
                 QPainter painter(this);
                 QPen paintpen(Qt::red);
                 paintpen.setWidth(10);
                 QPoint p1;
                 p1.setX(mFirstX);
                 p1.setY(mFirstY);
                 painter.setPen(paintpen);
                 painter.drawPoint(p1);
              }
  
  }
  </code></pre>
  
  <p>Help me to sort out what exactly problem is?</p>