Exibindo um fluxo de imagens com o Qt

A solução atual é assim:

//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->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();
}

Espero 20-40 quadros por segundo. O problema é que o desempenho aumenta muito com o tamanho. Com o tamanho em torno de fullHD, a pintura leva 1-2 ms. Mas se eu redimensioná-lo para 4k, fica muito lento (pintura de 16 ms). Existe alguma maneira de implementar a mesma funcionalidade, mas com menos consumo de recursos?

Teoricamente, se eu alterar a classe pai para QOpenGLWidget, o QPainter será executado com aceleração de hardware. Mas fazendo isso, ele corre ainda mais devagar.

questionAnswers(1)

yourAnswerToTheQuestion