PDA

View Full Version : drawText over a QPixmap



kaml.mish
20th January 2015, 10:00
Hello All
I am facing issue on drawText over a QPixmap. The error that gets displayed


QPainter::begin: Paint device returned engine == 0, type: 2 (painting/qpainter.cpp:1734, bool QPainter::begin(QPaintDevice*))
QPainter::setFont: Painter not active (painting/qpainter.cpp:4068, void QPainter::setFont(const QFont&))"


The code is given below


QImage originalImg = QImage(frame->data[0],1280,700,frame->linesize[0],QImage::Format_RGB888).copy();
qDebug()<<originalImg.size();
pxmap.fromImage(originalImg);
QPainter paint(&pxmap);
paint.setFont(QFont("Arial"));
paint.drawText(QPoint(200,200),"Test");

anda_skoa
20th January 2015, 10:09
You are most lilely drawing on a null pixmap, i.e. "pxmap" is most likely empty.

If you want "originalImg" in "pxmap" you need to assign the result of QPixmap::fromImage(), not discard it.

Cheers,
_

kaml.mish
20th January 2015, 11:30
The issue has been fixed