Qt QPixmap size

artoon picture artoon · Apr 24, 2013 · Viewed 9.6k times · Source

I would to have a QPixmap with the size 50 x 50. I tried :

QPixmap watermark(QSize(50,50)); 
watermark.load(":/icoMenu/preparation");

but the QPixmap take the image size.

I tried also :

QPixmap watermark(":/icoMenu/preparation");
watermark.scaled(QSize(50,50),  Qt::KeepAspectRatio);

but same result.

Answer

evilruff picture evilruff · Apr 24, 2013

You almost made it

QPixmap watermark(":/icoMenu/preparation");

QPixmap newPixmap = watermark.scaled(QSize(50,50),  Qt::KeepAspectRatio);