mardi 26 juillet 2016

QPaintDevice: Cannot destroy paint device that is being painted

This following code from this exercise does not display the image from the resources from Qt resulting in exiting with code zero:

#include "widget.h"
#include "ui_widget.h"
#include <QPainter>

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::paintEvent(QPaintEvent *e)
{

    QPainter painter (this);
    QPixmap img(":/tiger.jpg");

    resize(img.size());
    painter.drawPixmap(0, 0,img);
    QWidget::paintEvent(e);

}

Aucun commentaire:

Enregistrer un commentaire