Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[solved] QPainter:: drawImage resize



  • Can I resize the image before drawing?

    QImage img1;
    img1.load(filename);
    img1.scaled(width1, height1).scaled(width1, height1, Qt::IgnoreAspectRatio,Qt::SmoothTransformation);
    draw.drawImage(250,80, img1);

    It does not work.

    =====================
    solved by myself.
    QPainter::scale()


  • Lifetime Qt Champion

    Hi,

    scaled returns a new QImage so it should be:

    @QImage img2 = img1.scaled(width1, height1);
    draw.drawImage(250, 80, img2);@


Log in to reply