How can I set WebView content scale (qml QT 5.2)

前端 未结 1 1979
一个人的身影
一个人的身影 2021-01-14 07:26

I use qml WebView QT 5.2.

WebView {    
    anchors.fill: parent
    url: \"http://google.com\"   
}

Loaded page content is scaled dependi

相关标签:
1条回答
  • 2021-01-14 08:00

    To achieve the same scaling as in Picture 2 from you question , you have to set the user-agent property of WebView to the chrome one as follow :

    import QtWebKit.experimental 1.0
    ...
    WebView {    
    anchors.fill: parent
    url: "http://google.com"   
    experimental.userAgent:"Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36  (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36"
    }
    ...
    

    [Update] notice the difference between the 3 images from 3 different user-agent strings

    ------------------------------------------User-agent Android Browser------------------------------------------------

    "Mozilla/5.0 (Linux; U; Android 4.0.3; ko-kr; LG-L160L Build/IML74K) AppleWebkit/534.30    (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30"
    

    user-agent Android Browser

    ------------------------------------------user-agent Chrome Browser------------------------------------------------

    "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36"
    

    user-agent Chrome Browser

    ------------------------------------------user-agent Ipad-Macosx/Safari------------------------------------------------

    "Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25"
    

    user-agent Ipad-Macosx/Safari

    0 讨论(0)
提交回复
热议问题