Håvard Frøiland
Qt
KDE
Qt Jambi
WebKit
 in Qt, KDE, Qt Jambi, WebKit
 on Friday, January 11, 2008 @ 11:58

There is almost always room for a browser in a desktop application. You might need to show some help pages, documents, formated source code, xml or what not. And then you need a browser.

Up to now these browsers have often been limited to show some simple html. But with Qt 4.4 and Qt Jambi 4.4 we will have a proper WebKit integration and voila.. you have a full fledged web browser at your fingertips.

Let’s have a quick look at what it can do!

browser1.pngbrowser21.png

Oi, that looks promising.. Let’s have a look at the source code to this example that has been written using Qt Jambi.

import com.trolltech.qt.core.*;
import com.trolltech.qt.gui.*;
import com.trolltech.qt.webkit.*;       

class HelloWebKit extends QWidget {       

    private QWebView browser;
    private QLineEdit field;       

    public HelloWebKit() {
        field = new QLineEdit();
        browser = new QWebView();       

        QVBoxLayout layout = new QVBoxLayout(this);
        layout.addWidget(field);
        layout.addWidget(browser);       

        field.returnPressed.connect(this, "open()");
    }       

    public void open() {
        String text = field.text();       

        if (text.indexOf("://") < 0)
            text = "http://" + text;       

        browser.load(new QUrl(text));
    }       

    public static void main(String args[]) {
        QApplication.initialize(args);       

        HelloWebKit widget = new HelloWebKit();
        widget.show();       

        QApplication.exec();
    }
}

That wasn’t difficult was it :-) But can this actually render some normal webpages.. yes it can. So here goes another screenshot :-)

browser3.png

8 Responses to “Who needs a browser, Qt Jambi just got one?”

» Posted by matthias
 on Friday, January 11, 2008 @ 13:02

a web browser in qt… i’m still amazed every time i see it ! :) good job

» Posted by Ivan Čukić
 on Friday, January 11, 2008 @ 13:16

“Qt is definitely my favorite sin”
~ Al Pacino :)

This is (alongside Phonon in Qt) the greatest news I’ve heard in a while! Hats off!

» Posted by Bert JW Regeer
 on Friday, January 11, 2008 @ 14:40

Will there be a flash plugin available?

» Posted by haavardf
 on Friday, January 11, 2008 @ 15:05
Håvard Frøiland

We will work towards getting Flash plugin support. But right now we are not able to do this for all supported platforms so it will have to wait.

» Posted by Andrea
 on Tuesday, January 15, 2008 @ 11:45

Do you plan to make the “Document” available to the Qt API? This would be great to develop “complex” apps with QtWebKit.

» Posted by gritzko
 on Tuesday, January 15, 2008 @ 16:00

Hi! Great job!
A question regarding the API. Do you plan to provide access to Web Core objects (WebCore::Page)? As far as I see, currently it is private.

» Posted by Andrea
 on Tuesday, January 15, 2008 @ 19:27

… and to the “Document” …
Great job.

» Reply from Håvard Frøiland
 on Thursday, January 17, 2008 @ 09:23
Håvard Frøiland

Thanks :-)

The Qt Jambi api will follow the Qt api as close as possible. Have a look here to see what you can expect: http://doc.trolltech.com/main-snapshot/qtwebkit.html