Important: Please read the Qt Code of Conduct -

Screen aspect ratio and QWebView

  • Is there any way to change the aspect ratio in QGraphicsWebView or QWebView?

    The problem is that the LCD screen (800x480) has non-square pixels, thus the web pages are displayed incorrectly, e.g. circles become ovals. In other words, the screen DPI is different for X and Y. Basically I need to scale/zoom only one dimension.

    The software is used in Linux with Xorg, however, the graphics driver doesn't have an option to set the aspect ratio, it's a very simple framebuffer.

    Currently I'm using Qt 5.7.1.
    Thanks for ideas!

  • There are at least two ways to do this:

    • In user style sheet set transform: scaleX(...) (or scaleY) for html element. Use prefixed version -webkit-tranform if you don't use QtWebKit 5.212
    • Use QGraphicsView::scale with different values for x and y (if using QGraphicsWebView)

    Note that performance may decrease because of scaling

  • @Konstantin-Tokarev , thanks!
    QGraphicsView::scale() works great.