Wednesday, June 24, 2009

QtWebkit HTML5 practice

At phosphorescence: QtWebKit practice and phosphorescence: QtWebkit practice with QtRuby, I wrote QtWebKit sample program with Qt and QtRuby. And I also mentioned QtWebkit suports HTML5 in the phosphorescence: HTML5 support in QtWebkit. Then, can HTML5 be rendered with QtWebKit?

First, access to the HTML5 demo: Canvas | Drawing Board by Qt program.
#include <QApplication>
#include <QUrl>
#include <QWebView>
int main(int argc, char *argv[]){
QApplication a(argc, argv);
QUrl url("http://htmlfive.appspot.com/static/draw.html");
QWebView* webView = new QWebView();
webView->load(url);
webView->show();
return a.exec();
}

This runs successfully:
and can draw lines in canvas by mouse successfully, too.

Second, access to the HTML5 demo: Canvas | 1st-Person Gifter by QtRuby program.
require 'Qt4'
require 'qtwebkit'

Qt::Application.new(ARGV) do
  Qt::WebView.new do
    self.load Qt::Url.new('http://htmlfive.appspot.com/static/gifter.html')
    show
  end
  exec
end

Of course. this runs successfully too and move in maze with arrow keys:

Note that canvas tag is rendered easily, but that video tag depends on environment like video format and codec in client. At least, in my environment (on openSUSE 11.1), video tag isn't rendered not only with QtWebkit but also with HTML5 support browsers(Firefox, Opera, Konqueror).

No comments:

Post a Comment