Error Handler QtPainter Error engine == 0, Type 3, Painter not active

I am trying to draw some points of my image and I do not know why this does not work. I have defined QImage and I want to change 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 get

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

and in the following lines:

 QPainter::drawPoints: Painter not active 
+6
source share
2 answers
 QPainter::begin: Paint device returned engine == 0, type: 3 

An error means that the image you are trying to draw is null. Use isNull on cou to test this.
An image cause of zero can be due to incorrect height and largeur when creating the image or you have lost memory

+19
source
 QPaintEngine* eng = cou->painterEngine(); if(eng) { // create QPainter ... } 
+2
source

Source: https://habr.com/ru/post/943533/


All Articles