Giter Club home page Giter Club logo

qtmetaobjectwithcef's Introduction

Qt Meta Object With Cef

This is a sample project that integrates Qt's Meta Object System with CEF. (Only Tested under Linux)

Features

  • Supports passing any JSON stringifiable JS value to C++, namely

    • number (C++ number types(int, uint, float, double, etc), or the corresponding C++ enum member)
    • string (QString)
    • null (empty QVariantMap)
    • undefined (empty QVariantMap)
    • array (QVariantList, or QStringList)
    • boolean (C++ bool)
    • object (QVariantMap)
  • Supports overloaded Qt slots.

  • Requires greater type strictness than Qt WebKit; not as many implicit-cast as Qt WebKit.

    For example, Javascript number 1 is not considered C++ boolean true, and such attempt will result in promise's rejection on the JS side. However if this behavior is very desired, you can implement it in cg.js fairly easily.

  • Wraps Qt Slot calls with ES6 Promises.

  • Wraps Qt Signal emissions with event handlers.

  • C++ enums are partially supported. See Limitations below.

Limitations

  • The webview's bridge(or channel you may call), must be able to be compiled alone, without the WebView. This is because in this implementation, the bridge's meta information is determined before compile-time, instead of run-time.

  • You'll need to manually name all relevant C++ enums in cg.js.

  • Class forward cannot be used in bridge.h, if you have a QObject under the entrance Bridge object.

  • Assumes all Qt slots' invocation happens on the CEF's BrowserProcess.

How to use

  1. Generate a file describing bridge's structure.

    Compile CMake target QtMoExtractor, and run

    mkdir QtSample/cg
    ./QtMoExtractor > QtSample/cg/Bridge.def
    
  2. Generate the codes that bridges Qt and CEF

    cd QtSample
    node --harmony --harmony_destructuring ./cg.js
    
  3. Compile CMake target Application

  4. Run

    ./Application --no-sandbox
    

Requirements

  • CEF >= Branch 2623, equivalent to Chrome 49
  • C++14 compiler (With a few tweaks, this can be relaxed to C++11)
  • Recent versions of NodeJS
  • Qt5

License

Do whatever you want with it.

qtmetaobjectwithcef's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

jun-zhang

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.