Getting a higher quality image from QWebPage

  • I'm creating an image capture utility to allow uses to download snapshots of the charts and graphs that our web application generates. I've used the "Framecapture": example application as a starting point.

    It works well, but the image quality is too low for our needs. I need to be able to created higher resolution images.

    My understanding from reading the "QWebPage documentation": is that I need to increase the pixel density ratio in the Viewports Attributes.

    Unfortunately, I cannot figure out how to do that. Seems like I might need to do something with the X11 server that QWebPage talks to to get the Viewports Attributes, but I'm not a real expert in any of this stuff, so am having a hard time figuring it out.

    Could somebody please give me some pointers?

    The code that I'm using is basically like this:

    @QWebPage m_page;
    m_page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
    m_page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
    QImage image(m_page.mainFrame()->contentsSize(), QImage::Format_ARGB32_Premultiplied);
    QPainter painter(&image);
    painter.setRenderHint(QPainter::Antialiasing, true);
    painter.setRenderHint(QPainter::TextAntialiasing, true);
    painter.setRenderHint(QPainter::SmoothPixmapTransform, true);

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.