Category Archives: open source

Getting Started with Qt II: Qt Development Tools

In my last post, I tried to convey some of my excitement about the recently-LGPLed Qt framework for multiplatform develpment. I can list off great features all day and still not cover everything, but more importantly, Qt is great because there’s almost always something great about it that feels like it was built just for you. I think the best way to experience this is to take some time to sit down and play with it yourself, so I want to help you do just that.

Luckily, the 4.5 release has made it even easier to do just that with the introduction of the Qt Creator IDE. Binaries are available for Windows, Linux, and Mac OS X, so if it runs on your desk, it probably can run Qt Creator.

Qt Creator is included with the Qt SDK, which can be downloaded here.  I’ll cover integration with other IDEs like Visual Studio 2008 and Xcode in time, but for now, Qt Creator is the fastest way to get up and running to give things a try.

Rather than a typical hello world program, which is covered well elsewhere, I’d like to jump into some of the practical power of the framework by building a simple JavaScript interpreter. Think of it as a powerful version of the traditional calculator example.

Here’s a (terrible, hand-drawn) sketch of our goal:

qt_tut_thumb001

We have two major elements: the log area and a single-line text entry area with an “execute” button. On the back end, whatever you type into the text box will be executed by a script engine and the results are displayed in the log.  We’ll add some features as we go along to make it nicer.

We won’t be writing our own JavaScript engine.  Instead, we’ll leverage Qt’s QScriptEngine class so we can focus on adding features that are useful for us.  Have a look at that API and think about how you would implement this application.

Rather than publish this tutorial all at once, I’m going to post this in parts.  Think of it as a “Qt in 20 minutes a day” sort of tutorial.  If there are any topics you want to see covered or in expanded detail, let me know in the comments.

the wonderful world of webkit

I have the pleasure of working on an application that utilizes Apple’s open-source KHTML derivative, WebKit.  It’s the same engine that powers Safari and is among the most standards-compliant layout engines available to date.  After somewhat of a slow start, WebKit adoption is picking up among open-source projects, with the most notable being the Epiphany browser that ships with the GNOME desktop environment.  Epiphany is switching from  Gecko, the layout engine for Firefox, among others.  WebKit has also found a home in numerous OS X apps in a variety of contexts, and considering you can use WebKit in your app with zero lines of code, that’s not surprising.

But in addition to being friendly to the Cocoa side of development, WebKit is also great for developing websites with such old-fashioned things as HTML, CSS, and JavaScript.  In addition to its standards-compliance, it provides excellent DOM and JavaScript debugging tools as well.  These features not only exceed those provided by the former gold-standard of web developer browsers – Firefox – but also those of third-party plugins like the excellent FireBug.

For DOM inspection, WebKit (and thusly, Safari’s “Develop” menu) provides the “Web Inspector”, which is essentially Firefox’s DOM Inspector on steroids.  The typical DOM hierarchy display is there, along with element highlighting.

WebKit Web Inspector - DOM Hierarchy

In addition, a chronological breakdown of the page load sequence is provided to help optimize file loading patterns.  This view even provides hints, where available, on how to make your page load faster.

WebKit Web Inspector - Page Load Timeline

Most of the time, Web Inspector is all you need to make a great looking site, but sometimes your JavaScript code base becomes a bit unwieldy.  For those circumstances, Drosera is now available.  It’s still in its infancy and is not quite up to par with Firebug’s capabilities, but it does show potential and offers elementary functionality in that arena.

Putting all these things together, though, is what I find the most special.  Any WebKit instance in a Cocoa app can be inspected with Web Inspector and can be debugged with Drosera.

Drosera - Attach to Application

These tools are all still moving forward at a good clip. Drosera, in particular, needs some more love before it can be a class-leader, but the speed of WebKit’s development in general gives me faith that it too can be a best-in-class tool.