Skip navigation.
KDE Developer's Journals

Qt

brad hards's picture

Interoperability with Microsoft File Formats.

I recently realised that much of the code I find interesting is about interoperability. That is, I'm interested in making sure we can get at data in a range of formats. Work on libtiff, poppler, okular generators and openchange are all examples of that. I also like Qt as a very nice cross-platform API. The convergence of those interests is having Qt-style libraries and tools that can get access to data, especially data in widely used proprietary formats (e.g. those produced by Microsoft products).

I've set up a gitorious repository (http://gitorious.org/microsoft-qt-interop/microsoft-qt-interop) for some of that stuff.

oever's picture

SlideCompare: improving rendering of slides in KOffice

Rendering slides is a complicated business. Slides can contain tons of different features just like webpages can. People expect that presentations look the same in different programs. Perhaps not pixel-perfect but very similar nevertheless.

OpenOffice and KOffice (and the Maemo/Meego Office Viewer) both have ODF as their main file format. ODF is an open standard and this means exchanging data between these programs should be simple and lossless. To help the developers of these programs find differences in rendering of slides, I have written a program that loads a presentation and shows it as rendered by KOffice and OpenOffice.

As an added bonus, it also shows how these programs render PowerPoint files. PowerPoint files are converted to ODP first and then loaded into each of the two rendering engines. That gives four types of output:

  • Converted by OpenOffice to ODP and rendered by OpenOffice
  • Converted by KOffice to ODP and rendered by KOffice
  • Converted by KOffice to ODP and rendered by OpenOffice
  • Converted by OpenOffice to ODP and rendered by KOffice

You can see an example view in the screenshot and screencast below.

The code has been announced on the koffice mailing list.

Ogg Theora screencast of SlideCompare
Flash screencast of SlideCompare

jaroslaw staniek's picture

Qt for Android, 2nd try

Remember the last call? After less than 5 months we can see apparent success, and a lot more than a proof of concept.


Click to enjoy the show

oever's picture

Silent Metronome in QML

Tonight I could not attend band rehearsal so I used the time to play with the new QML language. There is a nice tutorial online and a good screencast.

QML allows one to write flashy applications with little code. My first QML program is a metronome. The N900 has a metronome program but it is rather boring. It does not look and feel like a real metronome. So I set out to write one in QML and managed to do so in 56 lines of QML. The interaction is simple: tap it to toggle between on and off and slide up and down to move the cross-bar on the metronome which will adjust the tempo in the range 40 to 208 beats per minute.

Without further ado here is the code. You can run it in qmlviewer. Two things are lacking at the moment: a nice SVG image of a metronome and of course the ticking sound. I am keen to find out how to make the metronome produce sound to make it useful.

import Qt 4.6

Rectangle {
    width: 640
    height: 480

    Rectangle { // metronome bar
        id: bar
        x: 320; y: 100; width: 30; height: 300
        color: "#aaaaaa"
        property double tempo: 120

        Rectangle { // weight on metronome bar that determines the tempo
            x: -15; y: parent.tempo; width: 60; height: 30
            color: "#aaaaaa"
        }

        transformOrigin: Item.Bottom
        rotation: 0
        rotation: SequentialAnimation {
            id: anim
            repeat: true
            NumberAnimation { to: 35; easing: "easeInOutQuad"; duration: 60000/bar.tempo }
            NumberAnimation { to: -35; easing: "easeInOutQuad"; duration: 60000/bar.tempo }
        }
    }

    Text { // tempo indicator
        x: 0; y: 0;
        font.pointSize: 24; font.bold: true
        text: bar.tempo
    }

    MouseRegion { // logic for tempo tuning and turning metronome on and off
        anchors.fill: parent
        property int start: -1
        property bool moved: false
        property bool wasrunning: true

        onReleased: { // start or stop the metronome
            anim.running = (moved) ?wasrunning :!wasrunning
            bar.rotation = 0
            start = -1
        }
        onPositionChanged: { // adjust the tempo
            moved = start != -1
            wasrunning = (moved) ?wasrunning :anim.running
            bar.tempo += (moved) ?(mouse.y - start) :0
            bar.tempo = (bar.tempo > 208) ?208 :bar.tempo
            bar.tempo = (bar.tempo < 40) ?40 :bar.tempo
            anim.running = false;
            bar.rotation = 0
            start = mouse.y
        }
    }
}

silent metronome in qmlreal metronome

oever's picture

Silent metronome

Silent metronome
jaroslaw staniek's picture

Mini quotes

I have self-backed policy of not mentioning competition if not really necessary, let it be G or M. So as a minimal effort I just quote these carefully selected bits (bias included!) instead of commenting the recent story:


[..] I think there is no reason to work on another package which is equivalent to Qt. If you want something like Qt, use Qt.

  --Richard Stallman, September 5, 2000 about then-disappearing need for creating Qt replacvement (aka project Harmony) after GPLing Qt

bille's picture

Qt 4.6 preview packages available for openSUSE

Since today is the big day when KDE trunk starts to depend on Qt 4.6, Raymond Wooninck (tittiatcoke), community packaging hero, has worked to provide packages of the unreleased Qt 4.6 in the openSUSE Build Service.

If you want to develop KDE trunk without the hassle of compiling Qt, you can use these packages (openSUSE 11.1). We'll be updating them every week to stay current as Qt 4.6 nears release. Please keep in mind that we're not responsible if you install them and your system KDE packages and anything else that depends on Qt stops working (although we will help you put things right, and the trolls will probably want to know about binary-incompatibility problmems) and when 4.6 is released, it will move into the KDE:Qt repo.

jaroslaw staniek's picture

Qt for Android

Shocked by the title? So I am.

Would you like to see Qt supported on this platform? Just two days ago the answer was like "But it's close to impossible".
Now with NDK 1.6 the "little robot" OS opens more to C/C++ native code. I am eager to read some analysis on the topic.

rich's picture

Adding custom objects to Qt Webkit

One question I've seen come up several times on #qt and qt-interest is how to
add custom (application specific) APIs to those available by default in
QtWebKit. This is actually pretty easy (once you know how) as I'll show
below. This post will show a simple example of how to make an object available
from javascript, including calling methods on the object and returning values
from C++.

There are two things you really need to know in order to perform this
integration, the first is the addToJavaScriptWindowObject() method of
QWebFrame, this allows will make the specified QObject visible from
javascript. The second thing you need to know is that objects published in
this way will vanish each time the javascript window object is cleared -
ie. every time the user navigates to a new page. To prevent this from causing
problems, QWebFrame provides a signal that tells you whenever the object is
cleared allowing you to re-add your custom API. This is actually much simpler
than it sounds!

The core of this is really implemented in two methods in the example, they're
shown below:

void MyApi::setWebView( QWebView *view )
{
    QWebPage *page = view->page();
    frame = page->mainFrame();

    attachObject();
    connect( frame, SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(attachObject()) );
}

void MyApi::attachObject()
{
    frame->addToJavaScriptWindowObject( QString("MyApi"), this );
}

This code is all that you need in order to make all of the public slots of the
MyApi object visible to javascript. The MyApi class provides two public slots:

public slots:
    void doSomething( const QString &param );
    int doSums( int a, int b );

The first slot simply logs a message to the debug output, the second returns
the sum of its two arguments (yes, slots can return things!). They're called
from javascript like this:

  MyApi.doSomething( 'Hello from JS page 2!!!!' );

  sum = MyApi.doSums( 2, 3 );
  alert( 'C++ says the sum is ' + sum );

And that's all there is to it! You can download the code from http://xmelegance.org/devel/qtwebkitextension.tar.gz.

oever's picture

Qt Overload: twittering birds

I just added some content to the new cute Qt community website.

Syndicate content