Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Webview content becomes empty if set Android targetSdkVersion 29 or 30
Qt 6.11 is out! See what's new in the release blog

Webview content becomes empty if set Android targetSdkVersion 29 or 30

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
1 Posts 1 Posters 396 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CellCS
    wrote on last edited by CellCS
    #1

    Testing QT version: QT5.12.4, QT 5.15.3
    Testing codes: QT example webview/minibrowser; my own project.
    Webview displays empty when set targetSdkVersion more than 28. But now Google requires targetSdkVersion 29 (at least).

    Html String (htmlStr): "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">\n<html><head><meta name="qrichtext" content="1" /><style type="text/css">\np, li { white-space: pre-wrap; }\n</style></head><body style=" font-family:'.AppleSystemUIFont'; font-size:13pt; font-weight:400; font-style:normal;">\n<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> <span style=" color:#110d62;"> </span><span style=" font-weight:600; color:#110d62;">Welcome to set Android TargetSdkVersion as 29</span></p>\n<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p>\n<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This is webview testing when set targetSdkVersion in QT. When set TargetSdkVersion as 29, if webview load content str has Qt-specific CSS properties like this, webview content display empty. Method is using webViewId.loadHtml(contentStr);</p></body></html>"

    Note: there are "-qt-block-indent", "qrichtext", "-qt-paragraph-" in html strings, if has no these (like following workedHtmlStr), webview works

    workedHtmlStr : "<!DOCTYPE html>\n<html>\n<head>\n<style>\nbody {background-color: powderblue;}\nh1 {color: blue;}\np {color: red;}\n</style>\n</head>\n<body>\n\n<h1>This is a heading</h1>\n<p>This is a paragraph.</p>\n\n</body>\n</html>"

    Function: webViewId.loadHtml(htmlStr);

    Testing results: (left is using 28, right one is using 29);
    WX20210108-170315@2x.png

    Any suggestion or solutions? or how to transfer qrich qt css to standard html str?
    I appreciate any comments or suggestions. Urgent bug for me. Thanks

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved