Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QtPainter Error Paint device returned engine ==0, type 3 ,Painter not active

Tags:

c++

qt

qpainter

I'm trying to paint some points of my image and I don't know why it doesn't work. I have defined a QImage and I want to modify some points.

QImage *cou= new QImage(height,largeur,QImage::Format_Mono);
    cou->fill(1);
    QPainter *fig=new QPainter (cou);
    for (i=0;i<size_;i++)
    {
        fig-> drawPoint(floor(propa[i]),nbmax[i]);
    }

When I execute the code I obtain

QPainter::begin: Paint device returned engine == 0, type: 3

and in the following lines:

QPainter::drawPoints: Painter not active
like image 247
user2269556 Avatar asked Apr 24 '13 12:04

user2269556


2 Answers

QPainter::begin: Paint device returned engine == 0, type: 3

The error means that the image you're trying to paint is a null image. Use isNull on couto check this.
The cause of image being null may be the wrong height and largeur params when the image is constructed, or you're out of memory

like image 66
spiritwolfform Avatar answered Nov 10 '22 09:11

spiritwolfform


QPaintEngine* eng = cou->painterEngine();
if(eng) {
//   create QPainter ...
}
like image 2
ebeglary Avatar answered Nov 10 '22 08:11

ebeglary