All Projects → mattixpet → webchannel-qml-example

mattixpet / webchannel-qml-example

Licence: Apache-2.0 license
No description, website, or topics provided.

Programming Languages

C++
36643 projects - #6 most used programming language
HTML
75241 projects
QML
638 projects
QMake
1090 projects

WebChannel QML Example

The Qt documentation doesn't seem to have an example using QML and WebChannel together, only C++ and WebSockets or other. So after painstakingly figuring this out myself through intense googling and trial and error, I have come up with this fairly minimal example of what I needed to do (which hopefully will save someone else some time), which was embed a local html file into a QML application and expose it to a C++ created object passed to my QML (and have two-way communication between the object and the html).

Here's a bunch of useful/less useful links which I encountered on my googling journey

Usage

Open the .pro file in QtCreator and hit Ctrl-R to run it. When you click the "Enlighten" button, you are invoking a function in a C++ object introduced to QML, which then in turn emits a signal which the embedded html receives and reacts to.

Notes

Another useful example would be something similar to this, but using WebSockets through QML instead of this qt.webChannelTransport, however, I couldn't figure out how to get that to work with my example.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].