diff options
author | Kai Koehne <kai.koehne@theqtcompany.com> | 2015-11-06 13:53:42 +0100 |
---|---|---|
committer | Kai Koehne <kai.koehne@theqtcompany.com> | 2015-11-17 14:23:48 +0000 |
commit | a6ae4526a390e7f53fbdb66bcb1d2c62816e3f95 (patch) | |
tree | df5d981732070d0adeb19d9e989cf0ea5eb3ab8c /examples/webenginewidgets/markdowneditor/resources/index.html | |
parent | af859695ec56390951204ce72eb6a888b1f9d0c8 (diff) |
Add 'markdowneditor' example
This example shows the use of QWebEngineView in a hybrid application,
and how one can leverage JavaScript libraries to provide functionality
with minimal effort.
QWebEngineView is used to preview a MarkDown document. The text is
exposed to the view through QWebChannel. An off-the-self js library
converts it to HTML.
Change-Id: I24c38106da3ec18975c71c16f7f7a58e93142f9e
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'examples/webenginewidgets/markdowneditor/resources/index.html')
-rw-r--r-- | examples/webenginewidgets/markdowneditor/resources/index.html | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/examples/webenginewidgets/markdowneditor/resources/index.html b/examples/webenginewidgets/markdowneditor/resources/index.html new file mode 100644 index 000000000..2f45479ed --- /dev/null +++ b/examples/webenginewidgets/markdowneditor/resources/index.html @@ -0,0 +1,32 @@ +<!doctype html> +<html lang="en"> +<meta charset="utf-8"> +<head> + <link rel="stylesheet" type="text/css" href="markdown.css"> + <script src="marked.min.js"></script> + <script src="qwebchannel.js"></script> +</head> +<body> + <div id="placeholder"></div> + <script> + 'use strict'; + + var placeholder = document.getElementById('placeholder'); + + var updateText = function(text) { + placeholder.innerHTML = marked(text); + } + + new QWebChannel(qt.webChannelTransport, + function(channel) { + var content = channel.objects.content; + updateText(content.text); + content.textChanged.connect(updateText); + } + ); + </script> +</body> +</html> + + + |