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

setDotsPerMeterX() function cannot work on my image



  • Hi,
    I want to use setDotsPerMeterX() function to change the DPI for the image, but it doesn't work, who can help me? thanks!

    the following is the test code:
    QImage img(100,100,QImage::Format_Mono);
    img.fill(Qt::color1);

    img.setDotsPerMeterX(img.dotsPerMeterX() * 2);
    img.setDotsPerMeterY(img.dotsPerMeterY() * 10);
    
    QPainter *pr = new QPainter;
    QRect r(10,10,80,80);
    pr->begin(&img);
    pr->drawRect(r);
    pr->drawLine(10,10,90,90);
    
    pr->end();
    
    ui->LabelShowImage->setPixmap(QPixmap::fromImage(img));

Log in to reply