Quantcast
Channel: QtWebEngine
Viewing all articles
Browse latest Browse all 13965

[[qanda:topic_unsolved]] what is the difference between running js inside webChannel and outside webChannel

$
0
0

Hi,
today, I am using mermaid.js to render the code

```mermaid
graph TD
A[方形] --> B(圆角)
    B --> C{条件a}
    C --> |a=1| D[结果1]
    C --> |a=2| E[结果2]
    F[竖向流程图]
```   (please ignore this brackets,  because the punctuation can not be showing correctly without other letters )

and part of my javascript code is :


    var source = document.getElementById('source');
    var placeholder = document.getElementById('placeholder');

    var updateText = function(text) {
      placeholder.innerHTML = md.render(source.innerHTML);
      // console.log(placeholder.innerHTML)
    }
    updateText();
    // new QWebChannel(qt.webChannelTransport,
    //   function(channel) {


    //     var content = channel.objects.content;
    //     content.textChanged.connect(updateText);
    //     updateText();
    //   }
    //   );

mermaid.js will find the div node with class name 'mermaid' and render the code inside the node when the document is changed.
this way, it can render the code correctly, but when I call updateText() inside QWebChannel, mermaid.js can not render the code.

what is the difference between running js inside webChannel and outside webChannel?
so how to let it work when i want to control when to render by using webChannel?

my project is at
project

thanks for your patient!


Viewing all articles
Browse latest Browse all 13965

Trending Articles