i have an image size 640*480, i am trying to resize it to 640*300.

my first try was:
QPixmap pixmap(QPixmap(imagePath));
pixmap.scaledToHeight(300,Qt::SmoothTransformation );
qDebug()<<pixmap.size();

but it also change width scale.---

then I tried
QIcon icon;
QSize size(640,300);
QImage image(QImage(imagePath));
icon.addPixmap(QPixmap::fromImage(image), QIcon::Normal, QIcon::On);
QPixmap pixmap = icon.pixmap(size, QIcon::Normal, QIcon::On);

qDebug()<<pixmap.size();

same problem---
any suggession is appreciating....thnks