QCustomPlot Discussion and Comments

Why QCPItemPixmap output "QImage: out of memory, returning null"?Return to overview

My image is a 608 * 480 png, and I set the coordinate with its width and height, then it outputs "QImage: out of memory, returning null". What's the problem? Can anyone help me out? Many thanks.

QCPItemPixmap *myImage = new QCPItemPixmap(this);
myImage->setPixmap(tMapImage);
this->addLayer("image");
myImage->setLayer("image");
myImage->topLeft->setType(QCPItemPosition::ptPlotCoords);
myImage->bottomRight->setType(QCPItemPosition::ptPlotCoords);
myImage->topLeft->setCoords(this->xAxis->range().lower, tMapImageSize.height());
myImage->bottomRight->setCoords(tMapImageSize.width(),this->yAxis->range().lower);


QImage: out of memory, returning null

i'm really confused as to what you are trying to do with those coordinates.

top left is 0,0
and bottom right is width,height

you are currently putting the top left at (unknown,480) and putting the bottom right at (608,unknown)
these coordinates are obviously wrong even if you assume that the unknown/undefined value of range().lower is equal to zero (my guess is it is negative).

assuming the value of lower is 0, your plot is going from (0,480) to (608,0), which is flipped in the y axis and probably causing your problem