Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QWebChannel + QWebEngineView to render markdown (example in qtcreator) has error notes printed to stdout...

QWebChannel + QWebEngineView to render markdown (example in qtcreator) has error notes printed to stdout...

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 1 Posters 452 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.
  • enjoysmathE Offline
    enjoysmathE Offline
    enjoysmath
    wrote on last edited by enjoysmath
    #1

    94313423-6579-44d7-82a5-8256d73bcf02-image.png ![0_1653459264802_e7600f1a-f06f-410d-aafc-4032baad5153-image.png](Uploading 0%)

    [14700:17216:0524/231205.700:WARNING:http_cache_transaction.cc(1189)] Unable to open or create cache entry
    [14700:17216:0524/231205.700:WARNING:http_cache_transaction.cc(1189)] Unable to open or create cache entry
    [14700:17216:0524/231205.749:WARNING:http_cache_transaction.cc(1189)] Unable to open or create cache entry
    [14700:17216:0524/231205.749:WARNING:http_cache_transaction.cc(1189)] Unable to open or create cache entry
    

    The index.html that I am rendering (includes KaTeX for math typesetting, and disables markdown):

    <!doctype html>
    <html lang="en">
    <meta charset="utf-8">
    <head>
      <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.15.1/dist/katex.min.css" integrity="sha384-R4558gYOUz8mP9YWpZJjofhk+zx0AS11p36HnD2ZKj/6JR5z27gSSULCNHIRReVs" crossorigin="anonymous">
      <script defer src="https://cdn.jsdelivr.net/npm/katex@0.15.1/dist/katex.min.js" integrity="sha384-z1fJDqw8ZApjGO3/unPWUPsIymfsJmyrDVWC8Tv/a1HeOtGmkwNd/7xUS0Xcnvsx" crossorigin="anonymous"></script>
      <script defer src="https://cdn.jsdelivr.net/npm/katex@0.15.1/dist/contrib/auto-render.min.js" integrity="sha384-+XBljXPPiv+OzfbB3cVmLHf4hdUFHlWNZN5spNQ7rmHTXpd7WvJum6fIACpNNfIR" crossorigin="anonymous"></script>
    
      <!-- <link rel="stylesheet" type="text/css" href="3rdparty/markdown.css">
      <script src="3rdparty/marked.js"></script> -->
      
      <script src="qrc:/qtwebchannel/qwebchannel.js"></script>
      <style type="text/css">
          body {
              overflow:hidden;
          }
      </style>
    </head>
    <body>
      <div id="placeholder"></div>
      <script>
      'use strict';
    
      document.addEventListener("DOMContentLoaded", function() {
          var placeholder = document.getElementById('placeholder');
    
          var renderMath = function() {
            renderMathInElement(document.body, {
              // customised options
              // • auto-render specific keys, e.g.:
              delimiters: [
                  {left: '$$', right: '$$', display: true},
                  {left: '$', right: '$', display: false},
                  {left: '\\(', right: '\\)', display: false},
                  {left: '\\[', right: '\\]', display: true}
              ],
              // • rendering keys, e.g.:
              throwOnError : false
            });
          }
    
          var updateText = function(text) {
              placeholder.innerHTML = text; // marked(text);
              renderMath();
          }
    
          new QWebChannel(qt.webChannelTransport,
            function(channel) {
              var content = channel.objects.content;
              updateText(content.text);
              content.textChanged.connect(updateText);
            }
          );
       });
      </script>
    </body>
    </html>
    

    So I took the canonical markdown example as found in Qt Creator examples, and I converted it to instead render using KaTeX's javascript lib as imported from remote CDN in the index.html.

    I get the above errors. I think since it does take about 20 seconds before the QWebEngineView actually displays the rendering to the screen (checking for loadFinished signal doesn't work btw), there must be something going wrong on the Javascript side that might be causing the delay. I think the errors get pooped out just as it finally loads visually.

    Good news is the program is useable after the initial 20second wait for the hangup. Can you understand what's happening just from your experience? Is there anything I can check or disable somewhere in order to not emit such errors, and even bypass whatever it's getting caught up on?

    https://github.com/enjoysmath
    https://math.stackexchange.com/users/26327/exercisingmathematician

    1 Reply Last reply
    0
    • enjoysmathE Offline
      enjoysmathE Offline
      enjoysmath
      wrote on last edited by
      #2

      Switching to a local copy of KaTeX and linking to index.html using "qrc:/KaTeX/katex.min.css" + 2 others and it seems to be working without running into those errors. A local copy is also better so that there's no dependence upon the users' internet connectivity.

      https://github.com/enjoysmath
      https://math.stackexchange.com/users/26327/exercisingmathematician

      1 Reply Last reply
      0
      • enjoysmathE Offline
        enjoysmathE Offline
        enjoysmath
        wrote on last edited by
        #3

        Actually found out what's taking it so long to render at the start (independently of the above mentioned errors) is that this will occur in Debug mode, but switching QtCreator to Release and the app loads instantaneously and also gets past the first render in usual speed that follows.

        Here's a video of it working, with auto-indexing:

        https://youtu.be/zsOy_ipdNM8

        https://github.com/enjoysmath
        https://math.stackexchange.com/users/26327/exercisingmathematician

        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