Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing a text in a QPixmap

I'm having what is follow:

QLabel* label_PM= new QLabel(this);
QPixmap PM ("C:/PM.jpg");
label_PM->setPixmap(PM);

I would like to insert to the PM a text like what is done in OpenCV cv::putText.

Nothing from research seems to resolve my problem,

Is there a way to do so?

like image 546
M.Mellouli Avatar asked Dec 11 '22 14:12

M.Mellouli


1 Answers

Drawing to a QPixmap is done through a QPainter. For example:

QPixmap pix = ...;
QPainter painter( &pix );
painter.setFont( QFont("Arial") );
painter.drawText( QPoint(100, 100), "Hello" );

This is a very basic usage, look at the QPainter documentation for more information.

like image 84
Dan Milburn Avatar answered Dec 14 '22 03:12

Dan Milburn