SlideShare a Scribd company logo
1 of 26
Download to read offline
Hybrid development
  using Qt WebKit
  http://src.develer.com/gitweb/pub/users/th30z/qtday/.git

   git clone git://src.develer.com/users/th30z/qtday/.git
WebKit

WebKit is an open source
web browser engine.
   state of the art rendering
    engine
   css/svg support
   super fast js engine
   plugin support
WebKit Everywhere
Components of WebKit

            CSS
      DOM          SVG
 HTML                        Canvas
         WebCore
   Rendering
                  JavaScriptCore
                    Worker            Storage
WebKit Library                Sockets
Different Ports
                            WebCore Graphics


Graphics
Context
                 Chromium             Gtk
           Mac                 Qt

                     Skia           Cairo
     Core Graphics          QtPainter

                                     Graphics
                                      Stack
QtWebKit
    A bridge between Qt and WebKit
With QtWebKit you can:
●   (easily!) embed a fully
    functional, standard
    compliant, web browser
    inside your application
●   inspect/extract the
    content
●   manipulate the web page
●   integrate your application
    with web services
QtWebKit (main) modules
   QWebView
          a QWidget (your browser window/tab)
   QWebPage
          a browsing session: settings + history + plugin +
             network + user interaction + document
   QWebFrame
          the document, one QWebFrame per html page or
             svg document.
          can have additional child frame (one per
             <frame>)
          magic happens here (qt ↔ page interaction)
QWebView
   QWebView is your “browser”
   QWebView is a QWidget
   QWebView exposes high-level signals/slots
           load() / reload() / stop()
           back() / forward()
           linkClicked() / loadProgress() /
               statusBarMessage()
   QWebView signals/slots are an excerpt of QWebPage +
    QWebFrame
QWebPage
   QWebPage is not a QWidget
           but a QApplication is still required
   QWebPage is the browsing ecosystem
           history + settings + plugins + network +
              document
   Interact with the document via the PageAction
QWebFrame
   QWebFrame is not a QWidget
   QWebFrame is a frame inside a web page
   each QWebPage object has at least one frame
           plus one QWebFrame for every <frame />
Using QWebView
#include <QtGui/QApplication>
#include <QWebView>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QWebView w;
    w.load(QUrl("http://www.google.com/"));
    w.show();
    return a.exec();
}
Content via String



QWebView webView;
webView.setContent(“<body>Hello World</body>”));
webView.show();
Capture to Image
QWebPage page;
…

QImage image(size, QImage::Format_ARGB32_Premultiplied);
image.fill(Qt::transparent);

QPainter p(&image);
page.mainFrame()->render(&p);
p.end();

image.save(fileName);
Qt & JavaScript

   eval javascript code inside the frame context
            QWebFrame::evaluateJavaScript
   inject a QObject into the frame context
Exposing to the World
                                                      Object Instance
                                                  From Qt/C++ to Javascript
                                  Variable name
                        Visible from JavaScript

 QWebFrame::addToJavaScriptWindowObject(QString, QObject *)


                                                             Exported

                                             Public Slots
QWebView w;
w.page()->mainFrame()                      Public Properties
                                                Signals
Exposing to the World
class Dialog : public QDialog {
   Q_OBJECT                                       Public Slots
     public:
                                                Public Properties
       Dialog (QObject *parent = 0);                 Signals
     public slots:
       void showMessage (const QString& message);
};



     QWebView webView;
     QWebFrame *frame = webView.page()->mainFrame();
     frame->addToJavaScriptWindowObject(“dialog”, new Dialog);
Exposing to the World


page()->mainFrame()->addToJavaScriptWindowObject(“dialog”, new Dialog);


      <input type=”button” value=”Click Me!”
          onClick=”dialog.showMessage(‘You clicked me!’)”>


                                           Public Slot
              Instance of
             Dialog Object
Signal & Slot
                        Javascript




           Signal           Slot
foobar.modified.connect(doSomething)


QObject                  JavaScript
Instance                  Function
Triggering Actions
class StopWatch : public QObject {
 Q_OBJECT                                 StopWatch::StopWatch (QObject *parent)
                                            : QObject(parent), m_tick(0)
 public:                                  {
  StopWatch (QObject *parent = 0);          QTimer *timer = new QTimer(this);
                                            timer->setInterval(1000);
 signals:                                   connect(timer, SIGNAL(timeout()),
  void tick (int t);                                this, SLOT(update()));
                                            timer->start();
 private slots:                           }
  void update();
                                          void StopWatch::update() {
 private:                                   emit tick(m_tick++);
   int m_tick;                            }
};

page->mainFrame()->addToJavaScriptWindowObject(“stopWatch”, new StopWatch);
                                 <script>
                                 stopWatch.tick.connect(function(t) {
                                    document.getElementById(‘tick’).innerText = t;
                                 });
                                 </script>
Coming back to Native

                                        JavaScript Code


    QVariant QWebFrame::evaluateJavaScript(QString)



  mostly key-value pair
(like JavaScript Objects)
       QMap
Coming back to Native
function getJsFuncMapValue() {     QVariant res;
   return {
      'test-list': [10, 20, 30],   res = frame->evaluateJavaScript("getJsFuncMapValue()");
      'test-string': "Hello",      QMap<QString, QVariant> resMap = res.toMap();
      'test-int': 20               QList<QVariant> resList = resMap[“test-list”].toList();
   }                               QString resString = resMap[“test-string”].toString();
}                                  int resInt = resMap[“test-int”].toInt();

function getJsFuncListValue() {
   return [40, 50, 60];            res = frame->evaluateJavaScript("getJsFuncListValue()");
}                                  QList<QVariant> resList = res.toList();

function getJsFuncIntValue(a) {
   return 80 + a;                  res = frame->evaluateJavaScript(“getJsFuncIntValue(2)”);
}                                  int resInt = res.toInt();
Maps Example
                 Javascript



     <script type="text/javascript">
     var map = null;
     window.onload = function() {
       map = new ovi.mapsapi.map.Display(
          document.getElementById("map"), {
             'zoomLevel': 12,
             'center': [43.779571,11.23726]
          }
       );
     }
     </script>
Maps Example
                                                                          QtWebKit
class MapView : public QWebView {
   ...
   MapView(QWidget *parent = 0) : QWebView(parent) {
       load(QUrl("maps.html"));
   }

     void moveTo (float lon, float lat) {
       QString js = QString("map.setCenter([%1, %2], true)").arg(lon).arg(lat);
       page()->mainFrame()->evaluateJavaScript(js);
     }

     void setZoomLevel (int level) {
       QString js = QString("map.setZoomLevel(%1, true)").arg(level);
       page()->mainFrame()->evaluateJavaScript(js);
     }
     …
};
                                                        MapView mapView;
                                                        mapView.moveTo(57.772232, 94.833984);
                                                        mapView.setType(MapView::Satellite);
                                                        mapView.setZoomLevel(6);
Hybrid Applications Qt + WebKit
   You can inject a QObject
           Call Public Slots
           Set/Get Public Properties
           Connect a signal to a javascript function
   Or you can extract from the frame context a function
    and call it from the C++ side.




                                 http://src.develer.com/gitweb/pub/users/th30z/qtday/.git

                                  git clone git://src.develer.com/users/th30z/qtday/.git
Questions?
 Hybrid development
   using Qt WebKit




           http://src.develer.com/gitweb/pub/users/th30z/qtday/.git

            git clone git://src.develer.com/users/th30z/qtday/.git


                                                                      25
THANKS !
                                Develer S.r.l.
                             Via Mugellese 1/A
                         50013 Campi Bisenzio
                                 Firenze - Italy




Contacts
Mail: info@develer.com
Phone: +39-055-3984627
Fax: +39 178 6003614
http://www.develer.com

More Related Content

What's hot

OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...ICS
 
My way to clean android v2 English DroidCon Spain
My way to clean android v2 English DroidCon SpainMy way to clean android v2 English DroidCon Spain
My way to clean android v2 English DroidCon SpainChristian Panadero
 
Building Web Apps Sanely - EclipseCon 2010
Building Web Apps Sanely - EclipseCon 2010Building Web Apps Sanely - EclipseCon 2010
Building Web Apps Sanely - EclipseCon 2010Chris Ramsdale
 
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with easeGDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with easeKAI CHU CHUNG
 
Meet the Widgets: Another Way to Implement UI
Meet the Widgets: Another Way to Implement UIMeet the Widgets: Another Way to Implement UI
Meet the Widgets: Another Way to Implement UIICS
 
The Next Step in AS3 Framework Evolution
The Next Step in AS3 Framework EvolutionThe Next Step in AS3 Framework Evolution
The Next Step in AS3 Framework EvolutionFITC
 
Google Developer Fest 2010
Google Developer Fest 2010Google Developer Fest 2010
Google Developer Fest 2010Chris Ramsdale
 
GDG Cloud Taipei: Meetup #52 - Istio Security: API Authorization
GDG Cloud Taipei: Meetup #52 - Istio Security: API AuthorizationGDG Cloud Taipei: Meetup #52 - Istio Security: API Authorization
GDG Cloud Taipei: Meetup #52 - Istio Security: API AuthorizationKAI CHU CHUNG
 
Vaadin7 modern-web-apps-in-java
Vaadin7 modern-web-apps-in-javaVaadin7 modern-web-apps-in-java
Vaadin7 modern-web-apps-in-javaJoonas Lehtinen
 
Using Grails to power your electric car
Using Grails to power your electric carUsing Grails to power your electric car
Using Grails to power your electric carMarco Pas
 
State of the Art OpenGL and Qt
State of the Art OpenGL and QtState of the Art OpenGL and Qt
State of the Art OpenGL and QtICS
 
Hiveminder - Everything but the Secret Sauce
Hiveminder - Everything but the Secret SauceHiveminder - Everything but the Secret Sauce
Hiveminder - Everything but the Secret SauceJesse Vincent
 
[JEEConf-2017] RxJava as a key component in mature Big Data product
[JEEConf-2017] RxJava as a key component in mature Big Data product[JEEConf-2017] RxJava as a key component in mature Big Data product
[JEEConf-2017] RxJava as a key component in mature Big Data productIgor Lozynskyi
 

What's hot (19)

Vaadin7
Vaadin7Vaadin7
Vaadin7
 
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
 
My way to clean android v2 English DroidCon Spain
My way to clean android v2 English DroidCon SpainMy way to clean android v2 English DroidCon Spain
My way to clean android v2 English DroidCon Spain
 
Android development
Android developmentAndroid development
Android development
 
Building Web Apps Sanely - EclipseCon 2010
Building Web Apps Sanely - EclipseCon 2010Building Web Apps Sanely - EclipseCon 2010
Building Web Apps Sanely - EclipseCon 2010
 
Qt Widget In-Depth
Qt Widget In-DepthQt Widget In-Depth
Qt Widget In-Depth
 
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with easeGDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
 
Meet the Widgets: Another Way to Implement UI
Meet the Widgets: Another Way to Implement UIMeet the Widgets: Another Way to Implement UI
Meet the Widgets: Another Way to Implement UI
 
Qt Workshop
Qt WorkshopQt Workshop
Qt Workshop
 
The Next Step in AS3 Framework Evolution
The Next Step in AS3 Framework EvolutionThe Next Step in AS3 Framework Evolution
The Next Step in AS3 Framework Evolution
 
My way to clean android V2
My way to clean android V2My way to clean android V2
My way to clean android V2
 
Google Developer Fest 2010
Google Developer Fest 2010Google Developer Fest 2010
Google Developer Fest 2010
 
GDG Cloud Taipei: Meetup #52 - Istio Security: API Authorization
GDG Cloud Taipei: Meetup #52 - Istio Security: API AuthorizationGDG Cloud Taipei: Meetup #52 - Istio Security: API Authorization
GDG Cloud Taipei: Meetup #52 - Istio Security: API Authorization
 
Vaadin7 modern-web-apps-in-java
Vaadin7 modern-web-apps-in-javaVaadin7 modern-web-apps-in-java
Vaadin7 modern-web-apps-in-java
 
Intro
IntroIntro
Intro
 
Using Grails to power your electric car
Using Grails to power your electric carUsing Grails to power your electric car
Using Grails to power your electric car
 
State of the Art OpenGL and Qt
State of the Art OpenGL and QtState of the Art OpenGL and Qt
State of the Art OpenGL and Qt
 
Hiveminder - Everything but the Secret Sauce
Hiveminder - Everything but the Secret SauceHiveminder - Everything but the Secret Sauce
Hiveminder - Everything but the Secret Sauce
 
[JEEConf-2017] RxJava as a key component in mature Big Data product
[JEEConf-2017] RxJava as a key component in mature Big Data product[JEEConf-2017] RxJava as a key component in mature Big Data product
[JEEConf-2017] RxJava as a key component in mature Big Data product
 

Viewers also liked

WebKit Security Updates (GUADEC 2016)
WebKit Security Updates (GUADEC 2016)WebKit Security Updates (GUADEC 2016)
WebKit Security Updates (GUADEC 2016)Igalia
 
Googleツールを使いこなして世界中の仲間と楽しく仕事を進めよう【初心者向け】
Googleツールを使いこなして世界中の仲間と楽しく仕事を進めよう【初心者向け】Googleツールを使いこなして世界中の仲間と楽しく仕事を進めよう【初心者向け】
Googleツールを使いこなして世界中の仲間と楽しく仕事を進めよう【初心者向け】Shinsuke Yashima
 
Fontconfigことはじめ
FontconfigことはじめFontconfigことはじめ
FontconfigことはじめTakao Baba
 
Chromium on Wayland Desktop (BlinkOn 7)
Chromium on Wayland Desktop (BlinkOn 7)Chromium on Wayland Desktop (BlinkOn 7)
Chromium on Wayland Desktop (BlinkOn 7)Igalia
 
Compiling and Optimizing Your Own Browser with WebKit
Compiling and Optimizing Your Own Browser with WebKitCompiling and Optimizing Your Own Browser with WebKit
Compiling and Optimizing Your Own Browser with WebKitSencha
 
A Browser for the Automotive: Introduction to WebKit for Wayland (Automotive ...
A Browser for the Automotive: Introduction to WebKit for Wayland (Automotive ...A Browser for the Automotive: Introduction to WebKit for Wayland (Automotive ...
A Browser for the Automotive: Introduction to WebKit for Wayland (Automotive ...Igalia
 
Taller: Licencias de Software Libre
Taller: Licencias de Software LibreTaller: Licencias de Software Libre
Taller: Licencias de Software LibreIgalia
 

Viewers also liked (7)

WebKit Security Updates (GUADEC 2016)
WebKit Security Updates (GUADEC 2016)WebKit Security Updates (GUADEC 2016)
WebKit Security Updates (GUADEC 2016)
 
Googleツールを使いこなして世界中の仲間と楽しく仕事を進めよう【初心者向け】
Googleツールを使いこなして世界中の仲間と楽しく仕事を進めよう【初心者向け】Googleツールを使いこなして世界中の仲間と楽しく仕事を進めよう【初心者向け】
Googleツールを使いこなして世界中の仲間と楽しく仕事を進めよう【初心者向け】
 
Fontconfigことはじめ
FontconfigことはじめFontconfigことはじめ
Fontconfigことはじめ
 
Chromium on Wayland Desktop (BlinkOn 7)
Chromium on Wayland Desktop (BlinkOn 7)Chromium on Wayland Desktop (BlinkOn 7)
Chromium on Wayland Desktop (BlinkOn 7)
 
Compiling and Optimizing Your Own Browser with WebKit
Compiling and Optimizing Your Own Browser with WebKitCompiling and Optimizing Your Own Browser with WebKit
Compiling and Optimizing Your Own Browser with WebKit
 
A Browser for the Automotive: Introduction to WebKit for Wayland (Automotive ...
A Browser for the Automotive: Introduction to WebKit for Wayland (Automotive ...A Browser for the Automotive: Introduction to WebKit for Wayland (Automotive ...
A Browser for the Automotive: Introduction to WebKit for Wayland (Automotive ...
 
Taller: Licencias de Software Libre
Taller: Licencias de Software LibreTaller: Licencias de Software Libre
Taller: Licencias de Software Libre
 

Similar to Hybrid Qt WebKit Development

Hybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKitHybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKitAriya Hidayat
 
Hybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKitHybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKitAriya Hidayat
 
Petri Niemi Qt Web Kit
Petri Niemi Qt Web KitPetri Niemi Qt Web Kit
Petri Niemi Qt Web KitNokiaAppForum
 
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"Provectus
 
Vaadin 7 CN
Vaadin 7 CNVaadin 7 CN
Vaadin 7 CNjojule
 
Workshop: Building Vaadin add-ons
Workshop: Building Vaadin add-onsWorkshop: Building Vaadin add-ons
Workshop: Building Vaadin add-onsSami Ekblad
 
03 - Qt UI Development
03 - Qt UI Development03 - Qt UI Development
03 - Qt UI DevelopmentAndreas Jakl
 
如何透過 Go-kit 快速搭建微服務架構應用程式實戰
如何透過 Go-kit 快速搭建微服務架構應用程式實戰如何透過 Go-kit 快速搭建微服務架構應用程式實戰
如何透過 Go-kit 快速搭建微服務架構應用程式實戰KAI CHU CHUNG
 
Google io bootcamp_2010
Google io bootcamp_2010Google io bootcamp_2010
Google io bootcamp_2010Chris Ramsdale
 
Gdg dev fest hybrid apps your own mini-cordova
Gdg dev fest hybrid apps  your own mini-cordovaGdg dev fest hybrid apps  your own mini-cordova
Gdg dev fest hybrid apps your own mini-cordovaAyman Mahfouz
 
Best Practices in Qt Quick/QML - Part III
Best Practices in Qt Quick/QML - Part IIIBest Practices in Qt Quick/QML - Part III
Best Practices in Qt Quick/QML - Part IIIICS
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web ToolkitsYiguang Hu
 
[C++ gui programming with qt4] chap9
[C++ gui programming with qt4] chap9[C++ gui programming with qt4] chap9
[C++ gui programming with qt4] chap9Shih-Hsiang Lin
 

Similar to Hybrid Qt WebKit Development (20)

Hybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKitHybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKit
 
Hybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKitHybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKit
 
Petri Niemi Qt Web Kit
Petri Niemi Qt Web KitPetri Niemi Qt Web Kit
Petri Niemi Qt Web Kit
 
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
 
Gwt RPC
Gwt RPCGwt RPC
Gwt RPC
 
Google Web Toolkit
Google Web ToolkitGoogle Web Toolkit
Google Web Toolkit
 
Treinamento Qt básico - aula II
Treinamento Qt básico - aula IITreinamento Qt básico - aula II
Treinamento Qt básico - aula II
 
JBoss World 2010
JBoss World 2010JBoss World 2010
JBoss World 2010
 
Vaadin 7 CN
Vaadin 7 CNVaadin 7 CN
Vaadin 7 CN
 
Workshop: Building Vaadin add-ons
Workshop: Building Vaadin add-onsWorkshop: Building Vaadin add-ons
Workshop: Building Vaadin add-ons
 
New Design of OneRing
New Design of OneRingNew Design of OneRing
New Design of OneRing
 
03 - Qt UI Development
03 - Qt UI Development03 - Qt UI Development
03 - Qt UI Development
 
如何透過 Go-kit 快速搭建微服務架構應用程式實戰
如何透過 Go-kit 快速搭建微服務架構應用程式實戰如何透過 Go-kit 快速搭建微服務架構應用程式實戰
如何透過 Go-kit 快速搭建微服務架構應用程式實戰
 
Google io bootcamp_2010
Google io bootcamp_2010Google io bootcamp_2010
Google io bootcamp_2010
 
Gwt
GwtGwt
Gwt
 
Gdg dev fest hybrid apps your own mini-cordova
Gdg dev fest hybrid apps  your own mini-cordovaGdg dev fest hybrid apps  your own mini-cordova
Gdg dev fest hybrid apps your own mini-cordova
 
Best Practices in Qt Quick/QML - Part III
Best Practices in Qt Quick/QML - Part IIIBest Practices in Qt Quick/QML - Part III
Best Practices in Qt Quick/QML - Part III
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web Toolkits
 
Google Web Toolkit
Google Web ToolkitGoogle Web Toolkit
Google Web Toolkit
 
[C++ gui programming with qt4] chap9
[C++ gui programming with qt4] chap9[C++ gui programming with qt4] chap9
[C++ gui programming with qt4] chap9
 

More from QT-day

EBV e Freescale: cosa possono fare per lo sviluppo delle vostre applicazioni ...
EBV e Freescale: cosa possono fare per lo sviluppo delle vostre applicazioni ...EBV e Freescale: cosa possono fare per lo sviluppo delle vostre applicazioni ...
EBV e Freescale: cosa possono fare per lo sviluppo delle vostre applicazioni ...QT-day
 
Qt Networking avanzato
Qt Networking avanzatoQt Networking avanzato
Qt Networking avanzatoQT-day
 
Qt Concurrent
Qt ConcurrentQt Concurrent
Qt ConcurrentQT-day
 
Qt Creator, l'arma segreta!
Qt Creator, l'arma segreta!Qt Creator, l'arma segreta!
Qt Creator, l'arma segreta!QT-day
 
Internazionalizza le tue applicazioni
Internazionalizza le tue applicazioniInternazionalizza le tue applicazioni
Internazionalizza le tue applicazioniQT-day
 
Home automation con BTicino MyHome
Home automation con BTicino MyHomeHome automation con BTicino MyHome
Home automation con BTicino MyHomeQT-day
 
EBV e Freescale: cosa possono fare per lo sviluppo delle vostre applicazioni ...
EBV e Freescale: cosa possono fare per lo sviluppo delle vostre applicazioni ...EBV e Freescale: cosa possono fare per lo sviluppo delle vostre applicazioni ...
EBV e Freescale: cosa possono fare per lo sviluppo delle vostre applicazioni ...QT-day
 
Welcome - Introduzione - Burkhard Stubert
Welcome - Introduzione - Burkhard StubertWelcome - Introduzione - Burkhard Stubert
Welcome - Introduzione - Burkhard StubertQT-day
 
Contribuire al Qt Project
Contribuire al Qt ProjectContribuire al Qt Project
Contribuire al Qt ProjectQT-day
 
Qt Platform Abstraction
Qt Platform AbstractionQt Platform Abstraction
Qt Platform AbstractionQT-day
 
Qtday Introduzione a qt quick
Qtday  Introduzione a qt quickQtday  Introduzione a qt quick
Qtday Introduzione a qt quickQT-day
 
Develer offering for Qt
Develer offering for QtDeveler offering for Qt
Develer offering for QtQT-day
 

More from QT-day (12)

EBV e Freescale: cosa possono fare per lo sviluppo delle vostre applicazioni ...
EBV e Freescale: cosa possono fare per lo sviluppo delle vostre applicazioni ...EBV e Freescale: cosa possono fare per lo sviluppo delle vostre applicazioni ...
EBV e Freescale: cosa possono fare per lo sviluppo delle vostre applicazioni ...
 
Qt Networking avanzato
Qt Networking avanzatoQt Networking avanzato
Qt Networking avanzato
 
Qt Concurrent
Qt ConcurrentQt Concurrent
Qt Concurrent
 
Qt Creator, l'arma segreta!
Qt Creator, l'arma segreta!Qt Creator, l'arma segreta!
Qt Creator, l'arma segreta!
 
Internazionalizza le tue applicazioni
Internazionalizza le tue applicazioniInternazionalizza le tue applicazioni
Internazionalizza le tue applicazioni
 
Home automation con BTicino MyHome
Home automation con BTicino MyHomeHome automation con BTicino MyHome
Home automation con BTicino MyHome
 
EBV e Freescale: cosa possono fare per lo sviluppo delle vostre applicazioni ...
EBV e Freescale: cosa possono fare per lo sviluppo delle vostre applicazioni ...EBV e Freescale: cosa possono fare per lo sviluppo delle vostre applicazioni ...
EBV e Freescale: cosa possono fare per lo sviluppo delle vostre applicazioni ...
 
Welcome - Introduzione - Burkhard Stubert
Welcome - Introduzione - Burkhard StubertWelcome - Introduzione - Burkhard Stubert
Welcome - Introduzione - Burkhard Stubert
 
Contribuire al Qt Project
Contribuire al Qt ProjectContribuire al Qt Project
Contribuire al Qt Project
 
Qt Platform Abstraction
Qt Platform AbstractionQt Platform Abstraction
Qt Platform Abstraction
 
Qtday Introduzione a qt quick
Qtday  Introduzione a qt quickQtday  Introduzione a qt quick
Qtday Introduzione a qt quick
 
Develer offering for Qt
Develer offering for QtDeveler offering for Qt
Develer offering for Qt
 

Recently uploaded

Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 

Hybrid Qt WebKit Development

  • 1. Hybrid development using Qt WebKit http://src.develer.com/gitweb/pub/users/th30z/qtday/.git git clone git://src.develer.com/users/th30z/qtday/.git
  • 2. WebKit WebKit is an open source web browser engine.  state of the art rendering engine  css/svg support  super fast js engine  plugin support
  • 4. Components of WebKit CSS DOM SVG HTML Canvas WebCore Rendering JavaScriptCore Worker Storage WebKit Library Sockets
  • 5. Different Ports WebCore Graphics Graphics Context Chromium Gtk Mac Qt Skia Cairo Core Graphics QtPainter Graphics Stack
  • 6. QtWebKit A bridge between Qt and WebKit With QtWebKit you can: ● (easily!) embed a fully functional, standard compliant, web browser inside your application ● inspect/extract the content ● manipulate the web page ● integrate your application with web services
  • 7. QtWebKit (main) modules  QWebView  a QWidget (your browser window/tab)  QWebPage  a browsing session: settings + history + plugin + network + user interaction + document  QWebFrame  the document, one QWebFrame per html page or svg document.  can have additional child frame (one per <frame>)  magic happens here (qt ↔ page interaction)
  • 8. QWebView  QWebView is your “browser”  QWebView is a QWidget  QWebView exposes high-level signals/slots  load() / reload() / stop()  back() / forward()  linkClicked() / loadProgress() / statusBarMessage()  QWebView signals/slots are an excerpt of QWebPage + QWebFrame
  • 9. QWebPage  QWebPage is not a QWidget  but a QApplication is still required  QWebPage is the browsing ecosystem  history + settings + plugins + network + document  Interact with the document via the PageAction
  • 10. QWebFrame  QWebFrame is not a QWidget  QWebFrame is a frame inside a web page  each QWebPage object has at least one frame  plus one QWebFrame for every <frame />
  • 12. Content via String QWebView webView; webView.setContent(“<body>Hello World</body>”)); webView.show();
  • 13. Capture to Image QWebPage page; … QImage image(size, QImage::Format_ARGB32_Premultiplied); image.fill(Qt::transparent); QPainter p(&image); page.mainFrame()->render(&p); p.end(); image.save(fileName);
  • 14. Qt & JavaScript  eval javascript code inside the frame context  QWebFrame::evaluateJavaScript  inject a QObject into the frame context
  • 15. Exposing to the World Object Instance From Qt/C++ to Javascript Variable name Visible from JavaScript QWebFrame::addToJavaScriptWindowObject(QString, QObject *) Exported Public Slots QWebView w; w.page()->mainFrame() Public Properties Signals
  • 16. Exposing to the World class Dialog : public QDialog { Q_OBJECT Public Slots public: Public Properties Dialog (QObject *parent = 0); Signals public slots: void showMessage (const QString& message); }; QWebView webView; QWebFrame *frame = webView.page()->mainFrame(); frame->addToJavaScriptWindowObject(“dialog”, new Dialog);
  • 17. Exposing to the World page()->mainFrame()->addToJavaScriptWindowObject(“dialog”, new Dialog); <input type=”button” value=”Click Me!” onClick=”dialog.showMessage(‘You clicked me!’)”> Public Slot Instance of Dialog Object
  • 18. Signal & Slot Javascript Signal Slot foobar.modified.connect(doSomething) QObject JavaScript Instance Function
  • 19. Triggering Actions class StopWatch : public QObject { Q_OBJECT StopWatch::StopWatch (QObject *parent) : QObject(parent), m_tick(0) public: { StopWatch (QObject *parent = 0); QTimer *timer = new QTimer(this); timer->setInterval(1000); signals: connect(timer, SIGNAL(timeout()), void tick (int t); this, SLOT(update())); timer->start(); private slots: } void update(); void StopWatch::update() { private: emit tick(m_tick++); int m_tick; } }; page->mainFrame()->addToJavaScriptWindowObject(“stopWatch”, new StopWatch); <script> stopWatch.tick.connect(function(t) { document.getElementById(‘tick’).innerText = t; }); </script>
  • 20. Coming back to Native JavaScript Code QVariant QWebFrame::evaluateJavaScript(QString) mostly key-value pair (like JavaScript Objects) QMap
  • 21. Coming back to Native function getJsFuncMapValue() { QVariant res; return { 'test-list': [10, 20, 30], res = frame->evaluateJavaScript("getJsFuncMapValue()"); 'test-string': "Hello", QMap<QString, QVariant> resMap = res.toMap(); 'test-int': 20 QList<QVariant> resList = resMap[“test-list”].toList(); } QString resString = resMap[“test-string”].toString(); } int resInt = resMap[“test-int”].toInt(); function getJsFuncListValue() { return [40, 50, 60]; res = frame->evaluateJavaScript("getJsFuncListValue()"); } QList<QVariant> resList = res.toList(); function getJsFuncIntValue(a) { return 80 + a; res = frame->evaluateJavaScript(“getJsFuncIntValue(2)”); } int resInt = res.toInt();
  • 22. Maps Example Javascript <script type="text/javascript"> var map = null; window.onload = function() { map = new ovi.mapsapi.map.Display( document.getElementById("map"), { 'zoomLevel': 12, 'center': [43.779571,11.23726] } ); } </script>
  • 23. Maps Example QtWebKit class MapView : public QWebView { ... MapView(QWidget *parent = 0) : QWebView(parent) { load(QUrl("maps.html")); } void moveTo (float lon, float lat) { QString js = QString("map.setCenter([%1, %2], true)").arg(lon).arg(lat); page()->mainFrame()->evaluateJavaScript(js); } void setZoomLevel (int level) { QString js = QString("map.setZoomLevel(%1, true)").arg(level); page()->mainFrame()->evaluateJavaScript(js); } … }; MapView mapView; mapView.moveTo(57.772232, 94.833984); mapView.setType(MapView::Satellite); mapView.setZoomLevel(6);
  • 24. Hybrid Applications Qt + WebKit  You can inject a QObject  Call Public Slots  Set/Get Public Properties  Connect a signal to a javascript function  Or you can extract from the frame context a function and call it from the C++ side. http://src.develer.com/gitweb/pub/users/th30z/qtday/.git git clone git://src.develer.com/users/th30z/qtday/.git
  • 25. Questions? Hybrid development using Qt WebKit http://src.develer.com/gitweb/pub/users/th30z/qtday/.git git clone git://src.develer.com/users/th30z/qtday/.git 25
  • 26. THANKS ! Develer S.r.l. Via Mugellese 1/A 50013 Campi Bisenzio Firenze - Italy Contacts Mail: info@develer.com Phone: +39-055-3984627 Fax: +39 178 6003614 http://www.develer.com