title: Qt - draw pixmap (.png file) with QPainter from resources
body: <p>I have some problems with drawing image on QWidget with QPainter from resources. I'm sure I'm missing something but I really dont know what. If I use absolute path, it works fine.</p>
  
  <p>So my question is: what should I do if I want to draw .png file from resources with QPainter? (What am I missing?)</p>
  
  <p>Here is my simple test code:</p>
  
  <p>Widget.h:</p>
  
  <pre><code>#ifndef WIDGET_H
  #define WIDGET_H
  
  #include &lt;QWidget&gt;
  #include &lt;QPaintEvent&gt;
  #include &lt;QPixmap&gt;
  #include &lt;QPainter&gt;
  
  class Widget : public QWidget {
      Q_OBJECT
  
      public:
          Widget(QWidget *parent = 0);
  
      protected:
          void paintEvent(QPaintEvent* e);
  
  };
  
  #endif // WIDGET_H
  </code></pre>
  
  <p>Widget.cpp:</p>
  
  <pre><code>#include "Widget.h"
  
  Widget::Widget(QWidget *parent): QWidget(parent) { }
  
  void Widget::paintEvent(QPaintEvent *e) {
  
      QPainter painter(this);
  
      QPixmap pixmap1("C:/Qt/Projects/pixmapTest/image.png");
      QPixmap pixmap2(":/img/image.png");
      QPixmap pixmap3("qrc:/img/image.png");
  
  
      painter.drawPixmap(10,10,50,50, pixmap1);  // this works
      painter.drawPixmap(10,70,50,50, pixmap2); // this not
      painter.drawPixmap(10,130,50,50, pixmap3); // this neither
  }
  </code></pre>
  
  <p>img.qrc file:</p>
  
  <pre><code>&lt;RCC&gt;
      &lt;qresource prefix="/img"&gt;
          &lt;file&gt;image.png&lt;/file&gt;
      &lt;/qresource&gt;
  &lt;/RCC&gt;
  </code></pre>
  
  <p>and .pro file:</p>
  
  <pre><code>#-------------------------------------------------
  #
  # Project created by QtCreator 2015-04-01T17:11:38
  #
  #-------------------------------------------------
  
  QT       += core gui
  
  greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
  
  TARGET = pixmapTest
  TEMPLATE = app
  
  
  SOURCES += main.cpp\
          Widget.cpp
  
  HEADERS  += Widget.h
  
  FORMS    +=
  
  RESOURCES += \
      img.qrc
  </code></pre>