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

Lighter weight browser?



  • I'd like to display .html help files in my QML app. I tried compiling and deploying the "minibrowser" and the "quicknanobrowser" examples for 32-bit Windows, and they both come out to over 150MB (release), but it looks like there might be DLLs and stuff that could be stripped out. Since "minibrowser" is based on "webview" and "quicknanobrowser" is based on "webengine", and the latter is (I believe) more full-featured than the former, I wouldn't expect them to wind up the same size.

    My application, without any browser, deploys at about 62MB, and that's before trying to strip anything out. Having it be 2.5x larger just to display some lousy help files with static text and images is painful. Are there any other existing bare-bones HTML decoders that can be used in QML? Or what can be stripped out of webview or webengine deployments? What about webkit?

    Ultimately, my requirements are:

    • file:// or qrc:// protocol only
    • HTML only
    • synchronous rendering, since it's all local
    • static text, .jpg, .gif, .png, and .svg
    • style sheets
    • scaling (zooming)
    • mouse and touch based links and scrolling
    • volatile history (forward and back buttons)

    What I don't need are JavaScript, Java, and forms. I also probably don't need tabs.


  • Moderators

    You can use QTextBrowser. This is what Qt Creator used to use for displaying Qt documentation/ help. I'm not sure if it will handle any CSS.

    In QML, you can use Text set to render RichText.



  • @sierdzio Since QTextBrowser is a Qt Widget, it doesn't play nice with my QML app. From what I've read, that sort of thing can be done, but it's not easy, probably beyond my Qt skills, and the work of incorporating a web browser display within QML has already been done in WebEngine, so I think for now I'll just put up with its bloat. Thanks for the pointers, though.


  • Moderators

    Yep, that's why I also mentioned plain Text QML component. I don't think it will handle "proper" HTML very well, but maybe it would work ok-ish for your specific needs.

    And yes, incorporating a widget inside QML is hard (but I thought maybe it would make sense to put it into a popup window in your app - then it can be a widget).


  • Lifetime Qt Champion

    Hi,

    To add to @sierdzio, you can take a look at KDAB's DeclarativeWidgets for that.



  • @SGaist That looks really interesting. Thanks.


  • Moderators

    @pderocco said in Lighter weight browser?:

    Since "minibrowser" is based on "webview" and "quicknanobrowser" is based on "webengine", and the latter is (I believe) more full-featured than the former, I wouldn't expect them to wind up the same size.

    On Windows, WebView uses Qt WebEngine behind-the-scenes -- that's why they're the same size.

    On mobile platforms, WebView uses the platform's native web renderer.



  • I needed an alternative to the browser libs provided by Qt. I searched and found this as one possibility:
    http://www.litehtml.com/

    However, I downloaded their test app and found it had trouble displaying anything with text entry including the Google page. It also requires you to write the rendering code to use it with whatever graphics package.

    I then turned to QTextDocument which supports a simplified version of html/css. This subset of html/css is VERY limited. So be forewarned before you decide on that path. This solution ended up being the choice for our solution and is already available in most text capable widgets in Qt. So the footprint in zero. Again, test this solution before you use it as it may not allow the needed text arrangement you get with common HTML solutions. For instance, I could not find a way to arrange two DIV elements next to each other on the same horizontal line. This is standard practice in most browsers.

    There may be other browser libs available as well. My guess is that most will require some assembly to be used with Qt.



  • FWIW, I eventually found that ordinary QML Text objects, when put into RichText mode, support enough HTML to do everything I wanted, much more elegantly than adding a ten-ton browser package. I didn't realize they supported embedded images and links, which are the features needed to transcend mere text display and make an actual browser.



  • @pderocco thank you for sharing your solution, and please don't forget to mark your post as solved.


Log in to reply