GithubHelp home page GithubHelp logo

isabella232 / qtwebchannel Goto Github PK

View Code? Open in Web Editor NEW

This project forked from qt/qtwebchannel

0.0 0.0 0.0 1.86 MB

Qt WebChannel

License: Other

C++ 75.86% Python 0.62% C 0.64% QML 19.71% CMake 3.17%

qtwebchannel's Introduction

Introduction

The Qt WebChannel module offers Qt applications a seamless way to publish QObjects for interaction with HTML/JavaScript clients. These clients can either be inside local Qt WebViews or any other, potentially remote, client which supports JavaScript, as long as a communication channel such as WebSocket is available.

Qt WebChannel uses introspection on the QObjects and sends this serialized data to the clients. There, with the help of a small JavaScript library, an object is created which simulates the API of the QObject. Any invokable methods, including slots, can be called as well as properties read and written. Additionally you can connect to signals and register JavaScript callbacks as handlers.

Dependencies

This module depends on Qt Core only. Optionally, an additional plugin for Qt Quick can be built, which makes it easy to use a QWebChannel from QML. Note that this module alone is not functional. It is being used in e.g. Qt WebKit to provide a seamless integration of QML/C++ QObjects into JavaScript clients. You can integrate it in your projects as well, by providing an implementation of the QWebChannelAbstractTransport class, see the standalone example for how to do this.

Building

qmake-qt5
make
make install

Usage from C++

To use the Qt/C++ library, add the following to your QMake project:

QT += webchannel

Then, in your C++ code, construct a webchannel, then publish your QObjects:

QWebChannel channel;
channel.registerObject(QStringLiteral("foo"), myFooObj);
....

Additionally, you need to provide a communication channel to the HTML client. One way is to use the Qt WebSockets module. On the HTML/JavaScript client side, you need to embed src/webchannel/qwebchannel.js and setup the connection to a client-side transport. An example which shows all this in action can be found in examples/standalone.

Usage from Qt Quick

For QML applications, use the following import:

import QtWebChannel 1.0

Then setup the WebChannel, register objects to it and connect to transport objects:

WebChannel {
    registeredObjects: [foo, bar, ...]

    transports: [yourTransport]
}

To see this in action, take a look at the test code in tests/auto/qml.

qtwebchannel's People

Contributors

alcroito avatar andrwwbstr avatar avolkov-astra avatar basyskom-meerkoetter avatar basyskom-swid avatar berndlamecker avatar dansoqt avatar ediosyncratic avatar gladhorn avatar jaheikk avatar janihe avatar jeromepasion avatar jobor avatar kkoehne avatar leena-miettinen avatar liangqi avatar milianw avatar msarehn avatar noamr avatar ossilator avatar oyheskes avatar psy-kai avatar stampho avatar thiagomacieira avatar tmcguire avatar toreinio avatar tronical avatar valdmann avatar vertrni avatar yuri-sevatz 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.