title: Displaying a stream of images with Qt
body: <p>The current solution looks like this:</p>
  
  <pre><code>//paintlabel.h
  class PaintLabel : public QWidget
  {
      Q_OBJECT
  
  public:
      explicit PaintLabel(QWidget *parent = 0);
  
  public slots:
      void setImage(char *img_ptr, QSize img_size, int pitch);
  
  protected:
      void paintEvent(QPaintEvent *event) override;
  
  private:
      QImage image;
  
  }
  
  //paintlabel.cpp
  
  PaintLabel::PaintLabel(QWidget *parent) : QWidget(parent)
  {
      setAttribute(Qt::WA_NoSystemBackground, true);
  }
  
  void PaintLabel::setImageLive(char *img_ptr, QSize img_size, int pitch)
  {
      image = QImage((uchar *)img_ptr, img_size.width(), img_size.height(), pitch, QImage::Format_RGB32).scaled(this-&gt;size());
      update();  
  }
  
  void PaintLabel::paintEvent(QPaintEvent *event)
  {
      Q_UNUSED(event);
      QPainter painter;
      painter.begin(this);
      if (!image.isNull()) {
          const QPoint p = QPoint(0,0);
          painter.drawImage(p, image);
      }
      painter.end();
  }
  </code></pre>
  
  <p>I expect 20-40 frames per second. The problem is, that the performance scales really bad with size. With the size around fullHD the painting takes 1-2 ms. But if I resize it to 4k, it gets awfully laggy (16 ms painting). Is there any way to implement the same functionality but with less resource consumption?</p>
  
  <p>Theoretically, if I change the parent class to QOpenGLWidget, the QPainter runs with hardware acceleration. But doing it, it runs even slower.</p>