Coder Social home page Coder Social logo

vishalbhardwaj26 / hw-html-with-qt Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 4.0 145 KB

Experimenting rendering HTML pages and JS communication in Qt

QMake 2.46% QML 2.36% C++ 45.49% HTML 8.88% JavaScript 40.81%
cpp qt qml qwidget html qwebchannel qtwebkit rendering-engine qtwebengine gui

hw-html-with-qt's Introduction

HTMLWithQt

Experimenting rendering HTML/JS pages in Qt and "JS-C++" communication in Qt

To Run this repo:

  • Open HTMLQtApp.pro file with Qt Creator
  • Configure project setting tab on left side panel

* Just check out that build dir should on on source level (parallel)

* Open **main.qml** under Resources and correct the url path according to your directory structure. Sorry that i have made it hard coded as of now.

About App

  • Initializes a WebSocket connection to the server.
  • Use Qwebchannel to register a particular object on server, so that it would be exposed to HTML/JS
  • Client JavaScript implementation of QWebChannel (qwebchannel.js ), like connecting to signals, calling slots, and handling property changes on the server.
  • Used WebEngineView to render HTML and JS content as app

Work flow:

GUI

More study

  • QtWebkit module of Qt made it possible to load HTML5 GUI in Qt and interaction of GUI elements with code behind in C++ using QtWebKit bridge in previous releases (based on WebKit rendering engine).
  • From Qt 5.3 QtWebkit is now moved in different direction along with "chromium" based browser and highly optimized "blink" as rendering engine, called as QtWebEngine (or QtWebKit 2.0).
  • QWebEngineView can be treated as a browser to host the HTML page.
  • QWebChannel provides a channel to communicate between C++ and JS code. It provides a mechanism to make your C++ code communicates with HTML JS and vice versa.

QtWebEngine

  • Integrates chromium's fast moving web capabilities into Qt.
  • Not just a port of the core HTML/CSS rendering engine, it is the entire Chromium platform

QWebChannel

  • QWebChannel provides a bridge between HTML/JS and C++.
  • Underlying transport mechanism, as a way to expose QObject to remote HTML/JS client.
  • Publishing a QObject derived object to a QWebChannel, and using the qwebchannel.js on the HTML side, one can transparently access properties and public slots and methods of theQObject.
  • Asynchronous API, makes it possible to talk to any HTML client, which could run on a local or even remote machine.
  • Limitation: A current limitation is that objects must be registered before any client is initialized.
  • So We should check to expose dynamically created objects, we have not yet.

Qt official blog talking about further direction with HTML technology

hw-html-with-qt's People

Contributors

vishalbhardwaj26 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.