Follow Slashdot stories on Twitter

 



Forgot your password?
typodupeerror
×
Programming Books GUI Media Software Book Reviews IT Technology

C++ GUI Programming with Qt 3 217

william_lorenz writes: "With the recent release of KDE 3.2 and KDevelop 3.0, and with the forming of the KDE Quality team as mentioned on Slashdot just days ago, it was an opportune time to read my newest book, C++ GUI Programming with Qt 3. (Qt is of course TrollTech's multi-platform windowing toolkit -- Win32, Linux, UNIX, and the embedded space with Qt/Embedded -- upon which KDE is built. There's a free version licensed under the GPL for non-commercial use and also a commercial version.)" Read on for the rest of Lorenz' review.
C++ GUI Programming with Qt 3
author Jasmin Blanchette, Mark Summerfield
pages 464
publisher Prentice Hall
rating 9
reviewer Bill Lorenz
ISBN 0131240722
summary A smooth introduction to best practices for Qt 3 application development.

I didn't have to force myself to read this one: the book grabbed my interest from the beginning. It's filled with just enough technical details to whet my technical curiosity, keep me turning pages, and provide the important information, clearly and concisely. I don't have much Qt development experience (none at all yet), although I am experienced in other windowing toolkits. The book quickly provided me with everything I need to know to get up and developing an application, and now I know where to quickly start.

Who's it for?

I am of course a novice Qt developer, yet one with a fair amount of IT experience, specifically with other windowing toolkits. I found this book not only a great introduction for those who want to get started with Qt, but it's also a trove of information for somewhat intermediate Qt developers. It's not for people who work for Trolltech or have already been developing feature-rich KDE applications; however, besides providing a great point of entry for new Qt developers, the book does touch on some more advanced topics. Technical books tend to age quickly, but I should note that the book is written by some of the people who brought us Qt 3 and are working on bringing us Qt 4, so this book should have a degree of forward compatibility.

What can I expect to learn?

The book is divided into two sections: "Basic Qt" and "Intermediate Qt" development.

The basic Qt section covers everything that someone new to Qt would probably want to learn, beginning with a simple application and an explanation of signals and slots (signals and slots work much the same way as windowing events in Java, for example, and can help to tell when a button or key is pressed). Signals and slots help make the sample application functional. This section also introduces the Qt reference documentation, available online as a reference during development, and Qt Designer, for those who want to use a graphical user interface to create components such as dialog boxes. A quick overview of some of the available widgets is next (widgets are graphical elements such as dialog boxes and buttons), which helps to give someone brand new to Qt development a feel for some of the components that come ready-to-build-upon. This is all covered in the first 38 pages of the book.

I should point out that I think that knowledge of the C++ programming language is essential if one is to learn good things from this book (I'm a big proponent of learning through experience, and you'll need to play with C++ code), but learning Qt and C++ development at the same time might help one come up with some interesting project ideas for learning!

After a quick introduction to creating custom widgets and double buffering (used in some cases to prevent screen flicker), the intermediate section starts by hopping right into layout managers, intended to make graphical forms and components beautiful (and more usable), just like tables helped to make HTML beautiful before CSS came around; layout managers help do for graphical application components what the font and alignment settings do for a word processor. The managers included are very similar to those used in Java's JFC/Swing stuff, and they work well. Also covered are methods for creating 2D and 3D graphics, drag-and-drop, and event processing. Compared to signals and slots, event processing gives the developer more control, and becomes important when writing custom widgets or changing the way an existing widget behaves.

Following this are sections on internationalization, providing online help within an application, multithreading for responsive applications, and Qt's platform-specific features. Qt works with Microsoft's ActiveX, for example, although this apparently requires the Qt/Windows Enterprise Edition as opposed to the free edition of Qt. It's important to point out that Qt implements its own threading capabilities, and the section on threads covers this in depth.

Conclusion

This is a great book for those interested in Qt and KDE development, cross-platform C++ graphical application development, and just making beautiful, functional applications. The book provides information that can't be had from the Qt API alone, and it does so in a way that kept me turning pages. Blanchette and Summerfield organized their text well, with logical chapters that make finding tips for that first application possible. This book gets twelve thumbs up from me.


Bill Lorenz is Vice-President of the Linux Users Group of Cleveland and is helping to organize the Ohio LinuxFest, 2004 edition (call for submissions now in the wild!). You can purchase C++ GUI Programming with Qt 3 from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

This discussion has been archived. No new comments can be posted.

C++ GUI Programming with Qt 3

Comments Filter:
  • Why to get this book (Score:5, Informative)

    by f0rt0r ( 636600 ) on Thursday March 18, 2004 @10:49PM (#8606090)
    Besides the good reviews the book got on my favorite QT forum -> http://qtforum.org/thread.php?threadid=316&sid=&th readview=0&hilight=&hilightuser=0&page =1

    The book comes with a free non-commercial version of the QT-Win( windows ) library ( QT 3.3.1, I believe ). The last time this was available was version 2.3.0, so if you want to get a non-expiring version for Windows, here is your chance.

    I also read the book is released under a special copyright license similar to the GPL ( the Perens License ), so that after a few months the electronic format of the book becomes legally distributable. Is that cool, or what?
    • online tutorials (Score:2, Informative)

      by CTib ( 4626 )
      Tutorial #2 [trolltech.com]
    • ... is give these guys a hand up: QT 3 Win32 [sourceforge.net]- this project would be totally awesome would it be done!
    • by Bruce Perens ( 3872 ) * <bruce@perens.com> on Friday March 19, 2004 @12:43AM (#8606812) Homepage Journal
      I also read the book is released under a special copyright license similar to the GPL ( the Perens License ), so that after a few months the electronic format of the book becomes legally distributable. Is that cool, or what?

      Yes. It's the Open Content License. It applies to the printed version today, meaning that you can shove it in a copier if you want and sell the copy, and it will apply to the electronic version when that is released. We usually do that about 3 months after the books reach store shelves. Source and unencrypted PDF will be available as usual.

      Unfortunately, I can't say the same for the CD. There is some proprietary software on the CD, I think a Windows version of Qt and some Borland stuff, which isn't really in line with the series policy. But I found out so late that it would have seriously messed things up for the Trolltech folks for me to insist on changes, so I let that go by this time (and made sure it would not happen again).

      Next books: Understanding the Linux Virtual Memory Manager [informit.com] next month, and Samba 3 by Example [informit.com] next week! Those are books 9 and 10 in the series.

      Thanks

      Bruce

    • I bought the book mainly because of the windows version of the library. There are four versions of the library on the CD:
      • Qt for Borland C++ Builder 5
      • Qt for Borland C++ Builder 6 trial edition
      • Qt for Visual C++ 6
      • Qt for Visual C++ .NET

      I've ported my app cubetest [vandenoever.info] to windows with the Builder 5 compiler. This compiler is however very old and the debugger works in DOS. That's not really a problem if the app would work well. Unfortunately, on other computers than my own the app seems to crash quite often eve

  • Pricing (Score:4, Insightful)

    by DRUNK_BEAR ( 645868 ) on Thursday March 18, 2004 @10:52PM (#8606110)
    Qt may be nice and cool since it's multiplatform, but the pricetag associated with it is not so nice and cool (starting at 1.55k$). Is anyone aware of OSS products similar to this?
    • Sorry... Not fully awake tonight... Skipped directly over the GPL comment...
    • There's this thing called GTK [gtk.org] that Gnome is based on, I hear it's pretty decent.
  • GPL Version (Score:5, Interesting)

    by bfree ( 113420 ) on Thursday March 18, 2004 @10:53PM (#8606115)
    Quoting from the submission:
    There's a free version licensed under the GPL for non-commercial use
    Pardon? How can a GPL be version be restricted like that? Of course it can be used commercially, just under the terms of the GPL.
    • Re:GPL Version (Score:2, Informative)

      by denks ( 717389 )

      Take a look at MySQL [mysql.com] to see how something can be offered both commercially and under the GPL.

      If you are the copyright holder for the entire code, you can license it however you please. The GPL does not remove the right of the copyright holder to do whatever they want with their own code

      • Re:GPL Version (Score:3, Informative)

        by bfree ( 113420 )
        A copyright holder can license it however they please, but if they license it under the GPL that's that. They could license it under a modified GPL which doesn't allow commercial distribution but I didn't think that was the case here! GTK on the other hand is under a modifed LGPL which allows derived binary only releases.
        • "They could license it under a modified GPL which doesn't allow commercial distribution but"

          Actually you can't modify the GPL. The FSF was smart enough to see confusion like this, so the GPL itself is copyrighted - thou shant make derivative licenses. Different license with similar terms? Sure. Modified GPL - not.

    • Re:GPL Version (Score:2, Interesting)

      by Trejkaz ( 615352 )
      The holders of the copyright can decide which license applies to which parties. Trolltech have simply decided that commercial parties need to pay them money to use it, while everyone else can use the GPL.
      • The holders of the copyright can decide which license applies to which parties. Trolltech have simply decided that commercial parties need to pay them money to use it, while everyone else can use the GPL.

        Doesn't work that way. The GPL explicitly permits your licensee (who in this case is not a commercial entity if you refuse) to give out the source code to anybody. If you additionally require your licensees not to give it to a commercial entity (which is legal), then it's no longer GPL.

        • Then make a commercial app based on Qt, sell it for a big profit, and see if Trolltech brush it off.
          • Here's the thing though.... it's entirely possible to make a Qt application without actually linking statically or dynamically to any of Trolltech's code, but instead just using interprocess communication.

            The GPL isn't sustainable through IPC because if it were, Photoshop would be violating the GPL because it can read picture files that were created with the Gimp, for example.

        • I think you're misunderstanding how the TT license works. Since Qt is GPL'ed, you're right, they can distribute it however they want. However, if you want to write a proprietory app using the library, you'll have to use a GPL-compatible license for your work. If you don't want to do that, you can pay Trolltech to license it to you under the terms of a non-GPL license.
      • Wrong. First, you can't do that (with the GPL anyway). Second, you can perfectly damn well use Qt for commercial applications. You just have to license your commercial application under the GPL, thus making it Free software.
    • Re:GPL Version (Score:5, Informative)

      by HuguesT ( 84078 ) on Thursday March 18, 2004 @11:18PM (#8606284)
      What they mean like that is that you are not allowed to develop closed source apps, free (as in beer) or otherwise, with the GPL version of QT.

      If you want to develop closed-source applications with QT you need to purchase the commercial version of QT, you can't use the GPL version.

      This way of doing things is compatible with the GPL.
      • Re:GPL Version (Score:5, Informative)

        by bfree ( 113420 ) on Thursday March 18, 2004 @11:25PM (#8606338)
        Right, so the original post should have read something like "There's a free version licensed under the GPL and also a commercial version for when that isn't appropriate" not that there is a GPL version for non-commercial use.
    • The reviewer miswrote. Must of have been confused with the Windows non-commercial (essentially a trial) version of Qt.

      You can sell KDE (example: most commercial Linux distributions.) You can sell GPL Qt applications.

      Nothing to see here. Move on folks.
    • There's the open QT/X11, which is GPL'd. No commercial restrictions apply.
      There's QT/Windows non-commercial, which is included with the book.
      There's QT/X11 & QT/Windows commercial (for making closed-source apps), which are not included with the book.

      Any clearer now?

      Kjella
    • You're correct, and the reviewer was confused. There is a GPL version, with which you can write GPL programs, whether commercial or not. However, if you want to write proprietary programs, not licensed under the GPL, then you need to pay them for a different license.

      Also note that there are actually four versions of QT - for QT X11, QT Embedded, QT Mac, and QT Win32. While you should be able to consider them as equivelant when you're writing the code, you'll need the appropriate one to compile the code on

  • by borgdows ( 599861 ) on Thursday March 18, 2004 @10:54PM (#8606124)

    programming GUI in C++... it's so nineties!! :o)

  • by hysterion ( 231229 ) on Thursday March 18, 2004 @11:10PM (#8606229) Homepage

    ...review everywhere! [slashdot.org]
  • C++ Skill... (Score:4, Interesting)

    by MP3Chuck ( 652277 ) on Thursday March 18, 2004 @11:12PM (#8606238) Homepage Journal
    What level of C++ knowledge is necessary to begin working with something like Qt (or other windowing libraries for that matter)? Having taken several semesters of C++ so far, I want to try something a little more tangible than the prompt stuff we've been doing.
    • Re:C++ Skill... (Score:5, Informative)

      by Otter ( 3800 ) on Thursday March 18, 2004 @11:20PM (#8606303) Journal
      Qt (or maybe Qt+KDE) is *the* place to start!

      I was in a similar position, with enough self-taught C++ to read and follow code but with no clue of how to build a meaningful GUI app. The great thing about Qt is that it genuinely makes OOP seem logical, in the way you make a bunch of objects and hook them together. I'd greatly recommend getting a free version of Qt, going through the tutorials and examples (that's the other great thing -- the documentation is superb) and maybe then trying KDevelop and the KDE libraries.

      Pardon me for gushing, but the combination of Qt and KDevelop was a truly empowering tool in my hands and I strongly recommend it to anyone in the same boat.

      • Re:C++ Skill... (Score:3, Informative)

        and maybe then trying KDevelop and the KDE libraries.

        Actually, I'd recommend that if he has KDevelop 3, he should use it to create a new Qt app--specifically, the one with the menus/toolbars/text editor. Why? It'll generate a good amount of code, specifically, it'll create a bare-bones text editor. He can then look through the code, compile and run the app, and see how it works, then playing around with it and making changes, seeing how those changes affect the app.

        Pardon me for gushing, but the combin
        • So I'm guessing it'd be easier to learn/develop Qt in a Linux environment, as opposed to Windows? KDevelop is obviously a KDE tool, and I don't see QtDesigner download available on TrollTech.

          It's not a big deal to have to use Linux... but Windows would be more convenient, since that's where I am most of the time.
      • Re:C++ Skill... (Score:2, Informative)

        by murrayc ( 19323 )
        Qt is not the place to start C++ if you want to learn C++ rather than Qt. You'll be shown Qt C++ language extensions that won't work in non-Qt projects, and you'll be shown unusual Qt- or KDE-specific build tools rather than standard GNU build tools. It's not as bad as learning C++ via Visual Studio and MFC, but it's not C++.
    • Not too much. You have to understand how classes and such work pretty well, but you can do many simple applications quite easily. Try the Qt Designer tutorial series (doc.trolltech.com)
    • What level of C++ knowledge is necessary to begin working with something like Qt (or other windowing libraries for that matter)? Having taken several semesters of C++ so far, I want to try something a little more tangible than the prompt stuff we've been doing.

      I'm guessing that you would have a basic understanding of most of the features of C++ and would understand the philosophy of OOP. The major step is now getting out of a command line user input/system output frame of mind to a GUI one. But startin
    • FYI: Most "tangible" programming has no interface. Libraries are where the most important code in your programs lie. Don't believe that because you aren't programming fancy gui's or graphics in your CS classes that you aren't doing anything tangible. The most effective code (kernel, libs, etc.) usually has no interface. I only say this because I too, once felt the way you do.
    • Re:C++ Skill... (Score:3, Informative)

      by zorander ( 85178 )
      What is neccesary to really work with Qt is an understanding of Object oriented *concepts*, not lanugage features. If you understand a given concept then the process of translating it into syntax can be learned in a few hours.

      Signals and slots are probably the biggest hurtle to jump over for basic application development in Qt. They're somewhat different than run of the mill callbacks. The event-driven programming paradigm takes a bit of getting used to.

      My advice to you, however, is to learn more language
  • The GPL'd code can be used commercially. In fact, it would VIOLATE THE GPL if they said it couldn't be used commercially. Indeed, most of the software in the linux distro box on my shelf is licensed under the GPL, and I paid good money for it.

    What it can't be is proprietary.

    I know Slashdot is not known for precision, but on an issue that gets everyone so worked up it's foolish to provoke people like this for no good reason.

  • by rthille ( 8526 ) <web-slashdot@ran g a t .org> on Thursday March 18, 2004 @11:32PM (#8606379) Homepage Journal
    From the FAQ:
    Qt/Embedded can be configured to for ROM requirements between 800k and 3M, depending on what features are enabled.
    I'm working on a new software load for the Ceiva (ver 2), and 800k ROM just for the graphics is way to heavyweight.
    • QT would be used where you wanted a very rich interface, and fitting that into 800k is amazing.

      Now, yeah, if you only have 400k then you don't want QT. You want something that's much lighter and has fewer features. But that's the nature of embedded programming and something that people who've never done it understand. You're highly constrained by the platform. Just as we were back in the day when 640k was all you had for os, code, and data on a 16 bit platform.

  • I've done a little Gnustep programming... is there anyone who's done both who can give a comparison? Would I be happier doing Qt?
  • Where's VB for unix (Score:5, Interesting)

    by superpulpsicle ( 533373 ) on Thursday March 18, 2004 @11:47PM (#8606483)
    Wasn't there a bunch of development on Visual Basic for unix platforms at one time with syntaxes similar to M$ VB from Visual Studio?

    Whatever happen to that?
  • by georgevulov ( 547520 ) on Friday March 19, 2004 @12:52AM (#8606874)
    Those looking for a fully free C++ toolkit should consider wxWidgets. With its superb sizer layouting system, rich api, native look, and great support (You often get replies from the authors themselves on the mailing lists), it is one of the best free toolkits around.

    Now, with the new partnership between wxWidgets and Borland, wxWidgets is likely to develop even more rapidly.

    Though wxWindows is free, unlike the free version of Qt it is not GPL, thus it can be used for commercial software development without worry.
    • You forgot to tell a few things:

      1) WxWindows break OO principles by using message maps; in other words, you don't overload a method, you define which callback to call using an id through a table. Message maps is a major reason why MFC sucks.

      2) There are quite a few bugs in it.

      In my opinion, not everything should be without price. Since Qt is the best toolkit there is, Trolltech deserves to get rich (hey, even BillG got rich from the horrible kludge that is WIN32).
      • > 1) WxWindows break OO principles by using message
        > maps; in other words, you don't overload a method,
        > you define which callback to call using an id
        > through a table. Message maps is a major reason
        > why MFC sucks.

        You have two choices with respect to connecting events to event handlers in wxWidgets:

        1. Use the aforementioned MFC-style message maps.
        2. Use the Gtk/Qt signal/slot-style wxEvtHandler::Connect() method.

        MFC-style message maps are more prevalent in the documentation, however. Bu
        • by master_p ( 608214 ) on Friday March 19, 2004 @11:36AM (#8610082)

          Use the Gtk/Qt signal/slot-style wxEvtHandler::Connect()

          Qt's Signals and Slots and wxEvtHandler::Connect() are two entirely different things:

          wxWindows requires connection to have a valid id number, which means a mess of ids in the first place. Qt's signals and slots does not require ids. Keeping track of ids is a nightmare, especially if you delete some.

          wxWindows connects functions to events, not methods to methods. With wxWindows, can't call an object method directly.

          Can't call private methods unless callback function is made friend to a class; which means callback function is visible to end-user (i.e. non-static).

          wxEvtHandler::Connect() is not typesafe: any wxObject-derived instance can be passed as user data. Qt's signals and slots and GTK's templated signals are much safer.

          Only events can be connected in WxWindows; which means you have to define event data structures, event ids, etc. In Qt, it could not be simpler: connect a method marked as signal to a method marked as slot.

          Using Connect() does not mean there are no message maps. In fact, all Connect() does is create a message map dynamically. Which means lots of wasted memory, memory fragmentation etc., slow execution etc

          Connect() callbacks accepts specific arguments; Qt's signals and slots accept any argument, just like a normal C++ function.

          Can you still claim that wxWindows are equivalent to Qt ? the callback task is much more time-consuming in wxWindows than in Qt. With Qt's signals and slots, one can make beautiful Model-View-Controller architectures; can't say the same with WxWindows.

  • If you already know C++, then it might be a good idea to check out the Independent Qt Tutorial.
    http://www.digitalfanatics.org/projects /qt_tutorial/
    (but without those spaces in the URL)
  • I'm interested in trying my hand at some QT work and this review makes it seem like this book is a good start for me. My concern is QT vs GTK and how much of my experiences will be useful if I change at some point. Whats the scoop?

    I'm not really interested in commercial application development - just learning.

The Tao is like a glob pattern: used but never used up. It is like the extern void: filled with infinite possibilities.

Working...