Who needs a browser, Qt Jambi just got one?

Posted by haavardf on January 11, 2008 · 8 comments

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

QShare(this)

Possibly related posts:

  1. Faking a web browser environment in QtScript

8 comments

1 matthias January 11, 2008 at 2:02 pm
 

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

2 Ivan Čukić January 11, 2008 at 2:16 pm
 

“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!

3 Bert JW Regeer January 11, 2008 at 3:40 pm
 

Will there be a flash plugin available?

4 haavardf January 11, 2008 at 4:05 pm
 

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.

5 Andrea January 15, 2008 at 12:45 pm
 

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

6 gritzko January 15, 2008 at 5:00 pm
 

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.

7 Andrea January 15, 2008 at 8:27 pm
 

… and to the “Document” …
Great job.

8 Håvard Frøiland January 17, 2008 at 10:23 am
 

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

Comments on this entry are closed.

Previous post:

Next post: