Ariya Hidayat
WebKit
Graphics View
Graphics Dojo
Posted by Ariya Hidayat
 in WebKit, Graphics View, Graphics Dojo
 on Tuesday, November 04, 2008 @ 11:30

The following example is an improved version of what I showed in Redwood City Developer Days: Google Search with thumbnail previews. This basically extends the previous demonstration of creating a preview using QtWebKit. The idea is fairly straightforward, just trigger Google Search with the search keywords, grab the result, iterate through the hits, get also the Google-served text snippet and then present everything using Graphics View. The challenge is to get the links pointed by Google. Because QtWebKit does not offer DOM API, this is thus done by injecting some JavaScript code using the infamous QWebFrame::evaluateJavaScript method (the code could use some improvement since I just crafted few quick-and-dirty JavaScript one-liners based on getElementsByTagName right before doing my WebKit talk). After that, generating the snapshot is easy, see the previous example.

Screenshot is provided below. However, much better if you just see the screencast (YouTube, blip.tv, 3.3 MB Ogg Theora video). Even better, just compile the code and give it a try!

svn checkout svn://labs.trolltech.com/svn/graphics/dojo/searchsnap
cd searchsnap && qmake && make && ./searchsnap

Exercise for the reader: use jQuery to get the hit list. More exercise: with Qt 4.5’s WebKit, you have HTML5’s getElementsByClassName at your disposal.

2 Responses to “Search with thumbnail preview”

» Posted by ulli
 on Wednesday, November 05, 2008 @ 02:05

Speaking of DOM support in QWebKit. Will we ever see this? Is it on the Roadmap for 4.6? Once it was promised for 4.5 but this did not turn out (unfortunately) as we all know… Having real DOM access would give much better and cleaner interaction possibilities, obviously.

So, any chance we’ll see (initial work of) this atleast in the WebKit git in the near future?

And thanks for your great work! You guys really rock!

» Posted by Abrax5
 on Friday, November 07, 2008 @ 10:48

More exercise, use xpath to do the job.



© 2008 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide.
All other trademarks are property of their respective owners.