gunnar
Qt Jambi
Posted by gunnar
 in Qt Jambi
 on Friday, September 28, 2007 @ 08:12

A few weeks back Eskil and I traveled to JavaZone, the biggest Java conference in Scandinavia, and Trolltech had a booth there and I did a presentation. We also got to meet several of our Qt Jambi users. Its always cool to see and hear what people are doing with the tools your developing and there are some pretty cool Qt Jambi things happening out there ;-)

Anyway.. One thing that came up when talking to people was that our signal / slots connections seem dangerous. So when it comes to the piece of code that looks like this:

ui.lineEdit.textChanged.connect(this, "setText(String)");

one sees the String and thinks that, if there is a typo there, my app is busted. Well… it would be if that piece of code wasn’t tested. Luckily most signal/slot connections are set up during object initialization, so that a typo here would be detected as you develop your class. Most development is done in a cycle of “develop and test and again”, so in practice this is mostly not a problem. And of course, we all know that developers never write errors in strings anyway, right? ;-)

Another problem that one will find with the current string approach is that it doesn’t give live feedback and syntax completion in IDE’s like Eclipse or IntelliJ. (Interestingly enough, it does in emacs, because my emacs completion is based on recently parsed strings instead of the actual code, which means it always completes something, though with a 5% error-ratio). So you have two problems with the current approach, first that Strings don’t feel save (even though they mostly are) and that they don’t give you live feedback. Internally we came up with an alternative quite some time ago and have been mentioning it to people who have asked, but I think its time to publish it.

The idea was to introduce a class QSignalHandlerX which offers complete compile-time type checking and offering better support for live feedback in IDE’s. The QSignalHandlerX class should have an abstract method that you had to reimplement, which did take correct types as parameter. Based on this you could create anonymous inner classes on the fly whenever you need to handle a signal and reimplement the method to handle the signal. Instead of the string connection you get:

new QSignalHandler1<String>(ui.lineEdit.textChanged) {
    public void handle(String s) {
        System.out.println("Got the string: " + s);
    }
}

In this case we use generics to match the types of the signal with the type of the signal handler. If the two have different signature you get a compile error and if you forget to add the String generics argument to the QSignalHandler you’ll get a warning telling you its “unsafe” or something similar. The 1 at the end of the QSignalHandler is the number of arguments, similar to the one in QSignalEmitter.Signal. This is already in our 4.4 branch, but the code is trivial so if you want this right away, I’ll give you a sample that you can “steal” and use.

package com.trolltech.extensions.signalhandler;

import com.trolltech.qt.*;

/**
 * Signal handlers are a convenience class that provides compile time type checking of signal / slot
 * connections.
 */
public abstract class QSignalHandler1<T> {

    /**
     * Creates a new signal handler that sets up a connection from the input signal to this object.
     * @param signal The signal to connect to.
     */
    public QSignalHandler1(QSignalEmitter.Signal1<T> signal) {
        signal.connect(this, "handle(Object)");
    }

    /**
     * Reimplement this function to handle responses to the signal this handler is connected to..
     * @param arg The Signal argument
     */
    public abstract void handle(T arg);
}

So as you can see, it is pretty straightforward. We move the string into the QSignalHandler class so that it is then checked, tested and verified once and for all and then all future use of QSignalHandler is checked. Because of the recurring generics type T we guarantee that the user uses the same type throughout the signal handler and its anonymous subclass.

If you have feedback on this API, please let us know…

Bradley T. Hughes
Qt
Threads
Painting
 in Qt, Threads, Painting
 on Thursday, September 27, 2007 @ 10:58

I just integrated a series of changes that adds support for doing multi-threaded text layout and printing. So it is now safe to use QFont and QFontMetrics outside the GUI thread. This means QPainter::drawText() works too (when painting on QImage, QPrinter, and QPicture). We’ve also done changes to QTextDocument that allow it to be cloned and passed off to a thread, so that all the layouting and printing happens without blocking the GUI.

For those interested, you can checkout tonight’s 4.4 snapshot. In tools/assistant/mainwindow.cpp, you’ll see code like this:

void PrintThread::start(QTextDocument *document)
{
    _document = document->clone();
    _document->moveToThread(this);
    QThread::start();
}

void PrintThread::run()
{
    _document->print(printer());
    delete _document;
    _document = 0;
}

void MainWindow::on_actionFilePrint_triggered()
{
    if (!QFontDatabase::supportsThreadedFontRendering()) {
        QPrinter printer(QPrinter::HighResolution);
        printer.setFullPage(true);

        QPrintDialog dlg(&printer, this);
        if (dlg.exec() == QDialog::Accepted) {
            qApp->setOverrideCursor(Qt::WaitCursor);
            tabs->currentBrowser()->document()->print(&printer);
            qApp->restoreOverrideCursor();
        }
        return;
    }

    PrintThread *thread = new PrintThread(this);

    QPrintDialog dlg(thread->printer(), this);
    if (dlg.exec() == QDialog::Accepted) {
        connect(thread, SIGNAL(finished()), SLOT(printingFinished()));
        connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));

        qApp->setOverrideCursor(Qt::BusyCursor);
        thread->start(tabs->currentBrowser()->document());
    } else {
        delete thread;
    }
}

void MainWindow::printingFinished()
{
    qApp->restoreOverrideCursor();
}

The Thread Support in Qt documentation has also been updated to show what is supported (Note, at the time of writing, the snapshot documentation has not been updated, check back later if you don’t have a 4.4 snapshot after 27 Sep 2007).

And just to be clear, painting onto a QPixmap or a QWidget outside the GUI is not supported at all. We are looking at ways of making the GL paint engine safe for painting on to FrameBufferObjects and/or Pbuffers, which may or may not make it into 4.4.

Thomas Zander
Qt
KDE
Posted by Thomas Zander
 in Qt, KDE
 on Wednesday, September 19, 2007 @ 13:47

Just recently within KDE the situation around printing flared up as many started to realize that the state of ‘kdeprint’ wasn’t really good enough for corporate use. I delved into this subject with the result that KDE is moving to using Qt classes for printing exclusively, and Trolltech putting considerable effort into making printing better and more usable.

One of the first steps I wrote about in a blog earlier today, and in this blog I wanted to preview some internal work that the printing guys here have been working on. I just compiled the code from the trying-out repository, so nothing is set in stone. But suffice to say I was very much impressed and thus started to write this blog :)

The way most applications work is that they have a print as well as a print-preview button. The print preview typically uses some default settings for page size / etc, which is suboptimal at best. It would be so useful to set the paper size and things like portrait/landscape directly in the print-preview dialog! And with this preview dialog you can :)

Print preview settings

Its also useful for those that want an overview;
print preview overview

This is, again, just a first version that we are working on. So be gentle when providing feedback :) We aim to have this in Qt4.4 and I’ll be sure to let you know when this hits the snapshots.

Thomas Zander
Qt
KDE
Posted by Thomas Zander
 in Qt, KDE
 on Wednesday, September 19, 2007 @ 10:43

Being able to do good printing one of those requests that come up very often. probably more often then “World peace” and “How to avoid hangovers after drinking too much”.
Like with world peace, the final answer is not going to be provided for quite some years yet. The topic is just too complex for one mind to answer (and we have some great minds in our communities). Now, we generally avoid the question altogether and just go and struggle though the headaces, which is mostly ok.

I’m often the perfectionist of the herd, aiming for the correct long-term solution. That helps with open source apps like KOffice2 which has seen a long development cycle which is really starting to pay off. My next bullet point is to give printing the love it deserves. And the printing code has been lonesome.

We are on a path of improvements, and I’m quite happy to see a constant set of improvements in Qt for printing. Which will mean a lot of applications out there will improve at the same time.
Qt4 has introduced a way to print to PDFs directly from a QPrinter instance, which is a great step forward since we used to rely on apps like ghostview to convert from postscript. This was known to have various problems. People are starting to use this more and more. But it has made another problem more clearly an itch to scratch.
The second longest request must have been to allow us to set custom page sizes. For example to print an envelope instead of a whole A4. So I decided to scratch that itch, and today I committed this change which you will find in the Qt4.4 snapshots tonight. There are 2 new methods on QPrinter. Namely; QPrinter::setPaperSize(Unit unit, QSizeF size) and QSizeF paperSize(Unit unit);
You can now do something like;
myPrinter.setPaperSize(QPrinter::Millimeter, QSizeF(162, 114));

Work is ongoing for printing, any feedback appreciated!

Thomas Zander
Qt
KDE
Contributors
Posted by Thomas Zander
 in Qt, KDE, Contributors
 on Wednesday, September 19, 2007 @ 09:03

As I’m new to this blog space, I thought I’d introduce myself. People reading planetkde.org certainly know me already, as I have been working on KWord for ages, with loads of blogs there about the cool new things that KOffice2 will bring.

Me moving to this site is a direct extension of that work, since I still have the dream that KOffice2 is going to rock the world and since KOffice is build on top of Qt I’m going to be working on making Qt be even better for text-based graphical work as well as printing here at Trolltech.

I’m firmly standing with one leg in the Trolltech community and the other one in the KDE community (which is a bit overwhelming at times, but a great experience on the whole!) so my work will partly be to keep the goals of the two communities aligned. Which in human terms simply means that I’m playing go-between :)

In other news, I moved from Holland to Norway some weeks ago, and I can say that I’m very much enjoying this change. Oslo is a wonderful city; with awesome people and lots of things to do. And I certainly enjoy going by bike to work every day (20mins). I’m slowly getting my head around the fact that on my way to work I bicycle past a genuine waterfall.

Anyway, enough about me, on to some coolness in Qt!

girish
Qt
KDE
News
Posted by girish
 in Qt, KDE, News
 on Tuesday, September 18, 2007 @ 16:23

So here is more dramatic news following the Qtopia Phone is completely GPL announcement.

A couple of years back, we made a big move by Open Sourcing Qt for Windows. The Open Source edition of Qt/Windows supported only MinGW (and MinGW/MSYS starting Qt 4.3). The MSVC Makefile, project generator and the Integration was available only to commercial customers.

Today (a week back actually), we made another big move. We have decided to support Visual Studio Express with Qt/Windows Open Source - we are dual licensing the MSVC Makefile and project generator (Sorry, no VS Integration for Open Source users). Many thanks to our PM Eivind Thronsen for making this happen. So when will you get this? Well, if you had checked out the 4.3 snapshots, the generators have been available for about a week now. The mkspecs are on their way. We did schedule it for Qt 4.4 but some quick work by Marius and André will see this feature in Qt 4.3.2. Why make you wait for 5 more months to get hold of such goodness ;-) ?

The Visual Studio Express environment is just so much superior and easier to use for existing Windows developers compared to what MinGW provides. We foresee many of the Open Source projects switching to VS EE for development after this change. Video killed the radio star?

englich
Qt
Aggregated
Patternist
Posted by englich
 in Qt, Aggregated, Patternist
 on Tuesday, September 18, 2007 @ 10:03

The Qt snapshots now includes support for XPath 2.0 and XQuery 1.0.

Being part of the XML library, the idea is that Qt 4.4 will ship with a C++ API for running and evaluating such queries. On the side too, is a command line tool called patternist, for quickly testing queries, scripting and old-school web solutions. But who cares, blogs with screenshots is the thing:

cli.png

Stronger XML support in Qt has been consistently asked for by users over a long time, with XPath being one of the main requests. Hopefully Patternist, with the help of KDE folks, users, and customers expressing what’s missing, will please those needs. Considering the similarities of XQuery and XSL-T, Patternist also serves as a foundation for implementing XSL-T, if so decided.

For KDE folks all this might ring a bell. Patternist was indeed first developed for a long time in the KDE repository, as part of KDOM. We just thought it would make a lot more use as part of Qt.

And I think exactly that makes this exciting. W3C’s XQuery working group has registered an astonishing number of exciting implementations. But for users, reliability is what matter in the end. Whether bugs will be fixed, whether people can answer questions, whether the piece is maintained and documented. Persistency. Trolltech swiftly carries this on its shoulders(assuming I brush my teeth and all that).

Combined with that Qt is open source and the Patternist SDK used for development is as well, this is like eating some nasty chocolate while at the same time singing a little duet with Miss Piggy. I can’t sing, nor can Piggy (although she tries), but you get my point.

Humble modesty aside, it is worth to mention that this still needs work. About 94% of the test suite is passed, the API needs more work, and there is performance issues.

Nailing test cases and trimming code paths are problems that have known solutions (though typically horrible to carry out). Harder is to know what people need and how they need it. It’s hard to guess what kind of APIs or extensions Amarok or KOffice or a GNOME or web application need.

If you got input, feel free to add a comment to the blog, send a report to Trolltech, grab me(FransE) on the Open Projects IRC network, or ask a question or two on the qt-interest mailing list.

The documentation starts over here.

lorn
Qt
Qtopia
KDE
News
Greenphone
Posted by lorn
 in Qt, Qtopia, KDE, News, Greenphone
 on Tuesday, September 18, 2007 @ 07:03

Ok, I have had to restrain myself for a few weeks now about this exciting and dramatic news..

“Qtopia Phone Edition to be completely open source under GPL license; Trolltech adds Neo as an open hardware platform for Qtopia development”

http://trolltech.com/company/newsroom/announcements/press.2007-09-17.9260755578

http://www.linuxdevices.com/news/NS5429713730.html

WOOT!

lorn
Uncategorized
Qt
Qtopia
KDE
QSA
Qt Jambi
News
Greenphone
Posted by lorn
 in Uncategorized, Qt, Qtopia, KDE, QSA, Qt Jambi, News, Greenphone
 on Wednesday, September 12, 2007 @ 01:08

Trolltech is presenting the fourth annual Developer Days events[1] in the US
and Germany. We invite free software developers to join without admittance
fee.

http://trolltech.com/company/newsroom/events/allevents/devdays2007

The events are taking place in Redwood City, California (October 3 & 4), and
Munich, Germany (October 16th & 17). If you are currently contributing to an
open source project, and would like to apply for free registration to the
event, please send us a short mail at devdays2007@trolltech.com, listing the
following:

Your Name:
Name of the open source project you actively contributing to:
URL for more project information:

We will review your entry and respond with registration information if
you qualify. We hope to see you at Developer Days!

Andreas
Qt
KDE
Posted by Andreas
 in Qt, KDE
 on Monday, September 10, 2007 @ 19:47

I just submitted a backport of QGraphicsItem::CacheMode to KDE4 SVN. The change is in Plasma::Widget, and gives Plasma the same speed boost that Qt 4.4’s QGraphicsItem eventually will have. For those interested, the change is also available in ftp://ftp.trolltech.com/qt/snapshots . Which is all of course completely irrelevant.

The important thing is - it’s my first KDE submit! I now qualify as a KDE developer. Right??

[21:05]  aseigo: if I submit, you sync and quickly check that it builds for you ok? I'm using 4.4, and I'm too lazy to recompile everything with 4.3. ;-)
[21:06]  _bibr: sure thing
[21:07]  aseigo: done!
[21:07]  bibr * r710738 workspace/trunk/KDE/kdebase/workspace/libs/plasma/widgets/ (widget.cpp widget.h):
[21:07]  Add CachePaintMode, as a temporary local back-port of
[21:07]  QGraphicsItem::CacheMode, which will appear in 4.4. I've chosen names
[21:07]  that aren't really good, but they're not misleading, and they don't
[21:07]  clash with the API in 4.4.
[21:07]  My first KDE submit :-DDD.
[21:07] * _bibr submits his very first change to KDE
[21:08]  s/KDE/KDE SVN/
[21:08] * aseigo builds
[21:08]  note: I haven't enabled the flag for any existing applets.
[21:08]  yep, it builds...
[21:08]  yohoo :-)