Boudewijn and Cameron Argue for Qt
Pages: 1, 2, 3

At this point Paul joined us. Paul has developed Unix applications for ages. He's now looking longingly at the market Linux offers.

Paul: I heard what you told the youngster. Look at me: I've got an enormous amount of Motif code and experience. Why should I switch?

Boudewijn: I honestly don't know. Should you switch? Do you still believe Motif has a future? When a commercial organization opens up a bit of legacy code, as the Open Group just did with Motif, or Borland with their database, I figure it's often the beginning of the end. ... It's better than keeping legacy stuff in a safe, but it's not promising.

Paul, look me in the eyes and tell me truthfully: Are you still having fun developing with Motif? Maybe you owe it to yourself to have some fun. Just try Python and Qt for a small personal project. I know I never had as much fun programming as I have now with PyQt ...

Paul: What interests me is Unicode. Using Unicode with Motif is a real problem -- it has been solved, more than once, but never really satisfactorily. I'm bit jealous of Thomas here, who has excellent Unicode support in Windows.

Thomas: I wish! It really only works for NT. Unicode for Windows 95 is ridiculous. I don't worry about it, though. Why should I use it at all? English was good enough for Saint Paul, so seven-bit ASCII should be good enough for you, Paul.

Boudewijn: Qt offers advantages for both of you. With Qt you've got full Unicode support both on Unix/X11 and on Windows 95/NT/2000. And don't think you don't need it. Even people who don't know an aigu from an umlaut now expect their applications to keep em-dash and en-dash straight, not to mention hyphens. If you do mathematics, you want all those mathematical symbols, don't you? Anyway, more and more of the world is computerizing. Do you think the Indians want to give up their devanagari script as they come online? Unicode is our best chance for a universal character set that everyone can use to exchange data. Grab that chance! I've got a nice little example of a Unicode-aware character selection window on my Web site, for example.

Cameron: I'll say it again: This is an example of how Qt is more native than native toolkits. MFC might be the default choice for Windows, but it doesn't give you the consistency of features between W95 and NT that Qt does.

Paul: I've got a technical question. Qt is a C++ library, right? I don't want to develop in C or C++ anymore -- it takes far too much time. So Python suits me fine. But how does PyQt handle C++'s pesky overloaded methods?

Boudewijn: Just fine. Phil has written an intelligent wrapper library that handles overloaded method selection based on the types of the actual parameter values present in the function call. Within Python, you can't create overloaded methods yourself, but there's no problem using the C++ overloaded methods. Look at this bit of code, where we first create a listviewitem without a parent, and then one with a parent:

    listItemParent=QListViewItem(self, "Parent")

Cameron: Phil told me, "I always think of myself as the author of SIP." SIP is his general-purpose system for binding together C++ and Python objects. The point is, he's done a lot to make it work properly. If you're anything like us, you'll find it easier accessing Qt through Python than with C++.

Paul: I've heard Qt is European. Is that right? Is it more popular in Europe than in the United States?

Cameron: Qt is the product of Trolltech, which is a Norwegian company.

Boudewijn: Likewise, a large amount of the KDE effort comes from Europe. The first Qt book was in German, and it has been translated into Japanese. I'm a European myself; I don't really know how popular Qt is in America, but it's pretty popular in these parts.

Cameron: North Americans are relatively fonder of GTK. It's a major religious issue for some people. There are plenty of Qt users hereabouts, though. There's a little suspicion around the world that U.S. software tends to be buggier and/or pricier. What's most certain is that Qt is a good Unicode citizen, and that's a big win in many places. With Python 1.6 supporting Unicode well, it makes PyQt a very attractive combination for internationalized application development.

Paul and Thomas: Well, we'll give it a try. What's the current release?

Boudewijn: The latest release of PyQt/PyKDE is 0.12. The license is no longer GPL (General Public License), but similar to the X11 license. A few bugs were fixed, a few functions added. But the most important new feature is the addition of the script. Yes! Full theme-able applications written in pure Python! Who doesn't want his app to look like it's crafted from expensive teakwood ...

Cameron: Before you go, I want to strongly recommend you read Trolltech's Qt documentation. It's one of the best features of the toolkit, and equally applicable if you're a PyQt developer. I think you'll like what you find.

Cameron Laird is the vice president of Phaseit, Inc. and frequently writes for the O'Reilly Network and other publications.

Boudewijn Rempt is a senior developer with Tryllian, a mobile agent company. He has worked with PyQt since its inception.

Related Articles

Qt Attracting Interest Among Application Developers

Visual Design With Qt

Discuss this article in the O'Reilly Network Forum.

Return to the O'Reilly Network Hub.