Slashdot Mirror


C++ GUI Programming with Qt 3

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.

54 of 217 comments (clear)

  1. Re:Online Books by Teh_monkeyCode · · Score: 5, Informative
    --
    -------
    Chunky Bacon
  2. Why to get this book by f0rt0r · · Score: 4, Informative

    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?

    --
    I can't afford a sig!
    1. Re:Why to get this book by Bruce+Perens · · Score: 5, Informative
      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 next month, and Samba 3 by Example next week! Those are books 9 and 10 in the series.

      Thanks

      Bruce

  3. online tutorials by CTib · · Score: 2, Informative
  4. Pricing by DRUNK_BEAR · · Score: 3, Insightful

    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?

    --
    DrkBr
    1. Re:Pricing by DRUNK_BEAR · · Score: 2

      Sorry... Not fully awake tonight... Skipped directly over the GPL comment...

      --
      DrkBr
    2. Re:Pricing by BiggerIsBetter · · Score: 2, Informative

      No, it's a fair question. There is still no free GPL Windows version. Possibly closest thing to an open source option is wxWidgets.

      --
      Forget thrust, drag, lift and weight. Airplanes fly because of money.
    3. Re:Pricing by Cthefuture · · Score: 3, Informative

      Yeah but wxWidgets (wxWindows) is kinda crappy.

      It's layers on layers of API's which just multiplies the complexity, amplifies bugs, and slows things down. Not to mention the bloat on bloat.

      Plus it's not really very cross platform, there are so many "This works on Gtk but not Windows" or "This works on Windows but not anything else", etc. Your code turns into #ifdef spaghetti hell. You might as well write native versions for each platform.

      The only truely viable cross platform (X11, Windows, MacOS) toolkits are:

      1. Qt (*too expensive, nice API, kinda bloated/slow)

      2. Fltk (tight/fast, nice API, *limited power, ugly/no themes yet)... My current favorite but I have a lot of custom code to make it look good and add features I need.

      3. Tk (*horrible API, not very flexible, can be slow)... I haven't used it much because the API sucks. Does this run under an X11 layer or native on MacOS?

      4. Gtk (C based painful API or Gtkmm C++ bloat, kinda bloated but relatively fast on X11, slow on Windows, MacOS uses X11 layer, *buggy as hell)

      --
      The ratio of people to cake is too big
  5. GPL Version by bfree · · Score: 4, Interesting
    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.
    --

    Never underestimate the dark side of the Source

    1. Re:GPL Version by denks · · Score: 2, Informative

      Take a look at MySQL 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

      --

      I am Monkey, the Great Sage, equal of heaven!
    2. Re:GPL Version by HuguesT · · Score: 5, Informative

      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.

    3. Re:GPL Version by bfree · · Score: 2, Informative

      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.

      --

      Never underestimate the dark side of the Source

    4. Re:GPL Version by bfree · · Score: 4, Informative

      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.

      --

      Never underestimate the dark side of the Source

    5. Re:GPL Version by GlassHeart · · Score: 2
      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.

    6. Re:GPL Version by alienw · · Score: 2

      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.

  6. wow! we are at the python/java/.NET era! by borgdows · · Score: 4, Funny


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

  7. Re:Sounds like I need it. by abes · · Score: 4, Informative
    Python has some nice bindings, and what better to go with a crossplatform toolkit than a cross platform interpreted language. Also, SIP (the tool used to create the bindings) finally works under OS X.

    A downside to QT is that it is not free under windows. While this might be okay with companies, if you ever considered writing crossplatform OSS programs, this can hamper things. There is a project porting the X11 version to windows, so its not a complete roadblock..

    Of course there is always GTK which has been known to also run under windows and OS X. It is not my intention to start any flamewars -- I am just pointing out that for those in favour of either toolkit there is plenty of crossplatformability.

    If either TK holds any major advantage its that GTK+ natively supports C code, but also has C++ bindings. The signalmm library that came out of gtkmm is actually really nice, and usable for other projects. However, in that case don't forget about boost, which also contains a signal library, not to mention a *really* nice interface to python (which I'm currently using in a project). Just be warned, you need a fast computer for compiling.

  8. Re:Sounds like I need it. by Trejkaz · · Score: 3, Interesting

    My current thoughts are using Qt/Java or Qt-Ruby, but it will largely depend what I decide to write.

    There are also C bindings for Qt in development, if I was going for an extremely simple application I would just use those.

    The #1 reason I would learn Qt, however, is to give myself a decent chance of contributing to the Psi project. I would be forced to learn C++ in that case but at least Psi's C++ is clean compared to many C++ apps I've seen. :-)

    --
    Karma: It's all a bunch of tree-huggin' hippy crap!
  9. Re:Sounds like I need it. by Brandybuck · · Score: 2, Insightful

    Don't igore the C++ nature of Qt! You don't need to know any of the ugly parts of the language. Qt makes C++ sensible. It's almost as if it were written by people who have to use C++ in their daily work :-)

    --
    Don't blame me, I didn't vote for either of them!
  10. The great thing with Qt: Write once,... by hysterion · · Score: 4, Funny
  11. C++ Skill... by MP3Chuck · · Score: 3, Interesting

    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.

    1. Re:C++ Skill... by Otter · · Score: 4, Informative
      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.

    2. Re:C++ Skill... by Quattro+Vezina · · 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 combination of Qt and KDevelop was a truly empowering tool in my hands and I strongly recommend it to anyone in the same boat.

      I fully agree with you here. Add Qt Designer to the mix as well--it'll really help with interface design. Though I would still recommend learning how to create widgets without Qt Designer first, in order to better learn how they work. After learning that, he should then use Qt Designer to set up the design of his apps.

      --
      I support the Center for Consumer Freedom
    3. Re:C++ Skill... by zorander · · Score: 2, Informative

      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 languages. There is nothing that teaches a concept as well as seeing how it manifests itself in multiple languages. C++ is not all there is to object oriented programming. At the very least, python and objective-C have lots to teach you about OOP. As far as your Qt-learning goals, you'll see in part how the problems solved by signals and slots in Qt have been dealt with in other languages with less cumbersome object orientated features, and in that way gain a deeper understanding of and appreciation for the design decisions made in the tools you use.

      In short the answer to your question is that you need to understand object oriented concepts with a little bit of depth. Class hierarchies, private, protected, friend, etc., Polymorphism both via operator overloading (which is used extensively in the Qt base classes), and via the 'common parent class (QObject)' approaches is also good to have a handle on.

      Really, though. Learn more languages. There's lots of fun stuff to be done in languages with large standard libraries like java and python (and objective-c if you happen to be a mac user), even without getting into user interfaces.

      Brian

    4. Re:C++ Skill... by murrayc · · Score: 2, Informative

      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++.

  12. Re:wow! we are at the python/java/.NET era! by abes · · Score: 3, Insightful
    I love C++. However, I constantly run into the problem that almost no one else in my field (science) understands C++. Some know C and matlab, but that's about the end of it.

    While for software engineers you might be able to argue that its their field, learn the language, you can't do that with people who use programming as part of their job, but not their main focus. I am constantly faced with the problem of either having other people understand my code, or writing things faster and with less bugs.

    The biggest obstacle is the difficult syntax of C++. After using it for enough time it's easy to forget, but it is a rather large learning curve -- especially for people who just want their code to work. The other complaints leveled at C++ (unless you are working with embedded systems, etc.) I think are just flamewar material.

    If there was one feature to pick out for why to use C++ I would have to say templates. Too bad toolkits like QT don't use them.

  13. Some reasons to use an OS' native toolkit by Rascasse · · Score: 5, Interesting
    Speaking as a relatively new Mac OS X user, I'd like to add the following reasons not to try to use cross-platform GUI toolkits. Looks are deceiving. Though they appear to look like native widgets, upon closer inspection some differences become apparent. Moreover, they may not act like native widgets. The keyboard shortcut equivalents may be different than what are available on the native OS' widgets. Scripting support may be available on the native OS' widgets, but unavailable on these cross-platform widgets. As minor as these differences may appear at first-glance, they add enough inconsistency to ruin the user experience - especially on OSes such as Mac OS X.

    I used to be a big fan of cross-platform GUI programming, but having worked on all variations of Windows, Linux desktops, and Mac OS X, I am now against the idea. I now believe if you're going to support a platform, use the native toolkits as they bring a level of consistency that is just not there with cross-platform toolkits. Having to use a GTK or QT-based app on Mac OS X these days proves to be tremendously frustrating. Text boxes don't have spell-checking or auto-completion. The red dot in the window decoration does not change if the document does. In fact, there is often no document-based implementation whereas there would be one if a native solution was developed. On Windows and Linux, the differences may only be cosmetic, but on OSes such as Mac OS X looks are only the tip of the iceberg with the problem. Cocoa widgets look pretty, but they also bring with them a lot of functionality that I've yet to see replicated on these cross-platform toolkits.

    So please, when in Rome do as the Romans do.

    1. Re:Some reasons to use an OS' native toolkit by Trejkaz · · Score: 2, Interesting

      The thing is, on a whole class of platforms, Qt is the "native" toolkit.

      But you're right. Spell checking isn't only a problem on OSX, it's even a problem on KDE. Even if every KDE app you own uses the built-in spellchecker to check every text entry box, a Qt app you compile today will not use it automatically.

      Cross-platform toolkits like wxWindows are supposed to deal with this sort of problem by just proxying the native toolkits. I'm not sure how well this works because I haven't used wx* either, mostly put off by the ugliness displayed in most screenshots from wx* apps.

      --
      Karma: It's all a bunch of tree-huggin' hippy crap!
  14. /s/non-commercial/non-proprietary by abe+ferlman · · Score: 4, Informative

    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.

    --
    microsoftword.mp3 - it doesn't care that they're not words...
  15. Somewhat OT: Something smaller than Qt3? by rthille · · Score: 2, Interesting

    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.

    --
    Awesome furniture, accessories and cabinetry in Santa Rosa, CA: http://humanity-home.com/
  16. How does Qt programming compare with Gnustep? by Lord+of+the+Fries · · Score: 2, Interesting

    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?

    --
    One man's pink plane is another man's blue plane.
    1. Re:How does Qt programming compare with Gnustep? by CoolMoDee · · Score: 2, Interesting

      being a Cocoa programmer myself, my guess is, maybe. Once having developed the *step way, I find it a pain to prgoram in environments that aren't message based (such as ObjC/*Step). One thing is for sure though, developing in QT would make your programs look normal in the average linux user's envionment, and would look prettier. Of course the horinztal menu patch could change part of that.

      --
      Jisho - A Japanese English German Russian French Dictionary for the rest of us.
  17. What you really, really should do... by Dog+and+Pony · · Score: 2, Interesting

    ... is give these guys a hand up: QT 3 Win32- this project would be totally awesome would it be done!

  18. Where's VB for unix by superpulpsicle · · Score: 4, Interesting

    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?

  19. Re:Sounds like I need it. by mangu · · Score: 4, Insightful

    My own two bits: I chose Qt because from the vey start it was easy to use. I wrote my first working Qt program twenty minutes after first taking notice of Qt. Despite the non-standard signal/slot interface, Qt is about as intuitive as a toolkit can be.

  20. Re:Sounds like I need it. by be-fan · · Score: 2, Informative

    The PyQt bindings are dreamlike. However, C++ with Qt is pretty decent. Qt + moc makes the language a lot more dynamic and easy to use than normal, and the library does a good job of managing its own memory.

    I greatly prefer Qt to Swing, though. Swing tries to be way to "pure" and as a result can be somewhat contorted.

    --
    A deep unwavering belief is a sure sign you're missing something...
  21. Re:Sounds like I need it. by illcare · · Score: 2, Informative

    wxWidgets is a free alternative for Qt (formerly known as wxWindows). I am currently using it and so far so good. It supports openGL, multiple languages. It is also documented quite well.

    Furthermore, we discussed crossplatform GUI toolkits before here and here

    Cheers,
    Ilker

  22. Re:Qt is not my favorite toolkit by be-fan · · Score: 4, Insightful

    At the time, every other GUI programming method used messages. From Xlib through to Win32, all GUI programming methods use messages.
    Agh! Xlib and Win32 are horrible GUI APIs! At least Xlib isn't largely at fault --- its not meant to be a full GUI API. Win32, however, has no excuse! Are you honestly telling me you think that Win32 (with its 200 line GUI hello world), is more sensical than Qt???

    It is considerably easier to thread a program that does not have a GUI wrapped up inside of a object than one that does not.
    Not really. Multi-threading fits pretty naturally with OOP. Look at the BeOS API (which has a lot of parallels with Qt) sometime. Could you give more detail on why you think this is the case?

    Object orientation brings bloat: often students would go way overboard in designing a solution, using 30 classes where 5 would suffice.
    That's because students, by and large, are stupid. That's why they are in school, to learn. You should have taught them to only use classes when they naturally fall out of the design of the program.

    Compilers are not good at OO: compared to C, C++ compilers are immature and buggy.
    That was true for the STL and templates, but Qt doesn't use the STL. Qt was very well supported on the compilers of the time. Again, specific examples?

    Thankfully, the GTK+ toolkit is winning the battle of the GUI toolkits.
    Really now? Seems pretty even to me.

    Students these days feel much more grounded in reality when they see their favourite applications such as mozilla, gaim, xchat, and xmms using the same toolkit they do.
    Bah! My favorite apps (Konqueror, Kopete, Ksirc, and Amarok) use my favorite toolkit (Qt).

    --
    A deep unwavering belief is a sure sign you're missing something...
  23. Re:Qt is not my favorite toolkit by Gauchito · · Score: 5, Insightful

    often students would go way overboard in designing a solution, using 30 classes where 5 would suffice

    You were their teacher? Guess who's fault this is.

  24. wxWidgets - fully free Qt alternative by georgevulov · · Score: 5, Interesting

    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.

    --
    TerraIM - my pet AIM client project.
    1. Re:wxWidgets - fully free Qt alternative by master_p · · Score: 2, Interesting

      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).

    2. Re:wxWidgets - fully free Qt alternative by WWE-TicK · · Score: 2, Insightful

      > 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. But if you don't wanna use them, you don't have to.

    3. Re:wxWidgets - fully free Qt alternative by master_p · · Score: 3, Informative

      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.

  25. Re:Gah! Kill Qt already! by Anonymous Coward · · Score: 4, Insightful

    Exactly how much code would you have to write to create your project with Qt (or GTK). Well thats EXACTLY HOW MUCH YOU ARE USING OF THEIR CODE. Thats how much time (time = money) you save by using it instead. money/time you didn't have to spend making your project.

    With GPL code, you pay for that time/money by giving back to the comunity that provided for you.

    With $2400 you pay for that time money by giving back to the comunity that provided for you.

    By paying nothing you basically take from the community and ask them to give you money back before they get anything of you.

    Don't want to give, don't take.

    People like you really piss me off. "They world owes me a job, the world owes me free music, the world owes me free software... But I owe the world nothing, it should pay me for my stuff"

    Sigh. If you can't afford the license cost your software must be pretty sucky anyway, as thats barely a couple of months wages.

  26. Re:Source of the books by Bruce+Perens · · Score: 2, Informative
    Hm. Please send a specific complaint about the phptr.com version to jht@samba.org (John Terpstra). In the meantime, I think you can go in the Samba CVS and find the "master" copy of the book source there.

    Thanks

    Bruce

  27. Re:So, if I understood correctly..... by botzi · · Score: 3, Interesting
    ...C++ is bad because its complex??? Sharpen up.
    C++ is *the* language, complex - sure enough, misunderstood - even more sure, 90% of today's CS stuff is drawned in its own mediocricy - count on that!!! this was one of the best books on programming languages I've ever read and if you're capable of understanding 50% of it you're sure to change your opinion on the language. Oh and...

    ...ever try reading someone else's C++?

    Yes, as well as C, Lisp, Java, PHP...etc. And for all those cases I found the following statement true: as long as the person who's wrote it is a <language name here> programmer and not someone *forced* to do the job in <language name here>, it will be a joy to read - in all the other cases the code readability depends on writer's & reader's intelligence.

    --
    1. No sig. 2. ???? 3. Profit!!!
  28. Re:Qt is not my favorite toolkit by zorander · · Score: 3, Insightful
    At the time, every other GUI programming method used messages.

    I don't know what it is that you're calling a message, but the MacOS X (previously NextStep) api (around since 1989, yes with an eight) has been using method calls (termed messages on objc) since the early days.

    Most GUI programming environments work through some form of callbacks. Qt is no exception, though signals and slots are sort of like callbacks on steroids (and definitely more akin to the messages in the NS api than anyhting else, again, your usage of messages is somewhere between narrow and uninformed)...GTK also has callbacks, as does Tkinter, both which have been around.

    Today's C++ compilers are generally nearly as fast and stable as their C counterparts. Seriously, they've been stable since at least 1999, and the good ones were stable before that. Qt deliberately created moc and avoided the STL to dodge the sketchy C++ issues of the early days so it was never much of an issue. Quite frankly you should be making the compiler choice for your students and suggesting that they work in a campus lab set up for it if they don't feel like dealing with compiler issues. You should be able to test an environment before they do. As the teacher of the course that is your responsibility.

    GTK+ is in no way winning. Qt is a much much cleaner implementation of GUI (somewhat comparable to the object oriented GTK wrappers, except it also provides the foundation classes that GTK lacks). Qt is also a win for portability as it provides a common layer for a large range of functionalities from networking to GUI to openGL across the three major platforms. Last time I checked, gtk2 for windows was less than perfect and a native gtk2 port for mac os X is not even on the horizon yet. is Gnome very popular? yes. is KDE? yes. They're both out there and they're both up there. Just cause you prefer gnome doesn't mean that it's time to declare a winner.

    You're making some awfully harsh statements here that appear to have no real backing. Yes you tried to teach Qt and failed. perhaps the student's weren't ready for it? perhaps your campus computing environment wasn't ready for it? perhaps you weren't prepared to teach it? I wouldn't go blaming the GUI toolkit first thing.

    Brian

  29. The Independent Qt Tutorial by Xhargh · · Score: 2, Informative

    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)

  30. Re:Qt is not my favorite toolkit by rikkus-x · · Score: 4, Insightful
    I'm posting anonymously for obvious reasons.

    Because you are a coward?

    I'm a Teaching Fellow (TF) at Harvard,

    How awfully nice for you. May we therefore assume that you're more clever than the rest of us?

    Object orientation as a language prescription is a bad idea: At the time, every other GUI programming method used messages. From Xlib through to Win32, all GUI programming methods use messages. It is considerably easier to thread a program that does not have a GUI wrapped up inside of a object than one that does not.

    Qt uses messages. Did you really use Qt or are you making this up?

    What makes it easier to thread a program that does not 'have a GUI wrapped up inside of an object' [sic]?

    Object orientation brings bloat: often students would go way overboard in designing a solution, using 30 classes where 5 would suffice.

    What is so terrible about having a large number of classes? Only the most novice (OO) programmers I've met shy away from creating more than the 'bare minimum' of classes.

    What does this have to do with Qt, anyway?

    Compilers are not good at OO: compared to C, C++ compilers are immature and buggy. Sure, this is a compiler issue not a toolkit issue, but I found it frustrating debugging student's choice of compiler rather than choice of code.

    This is plain wrong. There are some great C++ compilers out there and some servicable ones. Intel's C++ compiler and GNU G++ are examples of the former, Microsoft's of the latter. Why did you let students choose their own compiler?

    Thankfully, the GTK+ toolkit is winning the battle of the GUI toolkits. Students these days feel much more grounded in reality when they see their favourite applications such as mozilla, gaim, xchat, and xmms using the same toolkit they do.

    That first sentence is flamebait; the second is inaccurate. Mozilla isn't built on GTK+: perhaps you meant Firefox?

    The parent post smells funny. I call shenanigans.

    Rik

  31. Re:Qt is not my favorite toolkit by tequesta · · Score: 2, Interesting

    First of all, what keeps you from combining object orientation and messages? An event is a message that gets placed in a queue and taken out sometime later and delivered. Objects register for the events they want to receive. Perfectly threadable, perfectly object-oriented and moreover perfectly obvious to understand.

    Second, if your students over-design, maybe you're doing something wrong as a teacher? I'm a research fellow at a German university and teach students myself. It's true, it takes a while for them to "grok" OO. But once they do, it's the most obvious and simple concept there is.

    Third, you base your statement that "compilers are not good at OO" on current C++ compilers. Well, (although this is a Qt thread) C++ is not the only object-oriented language around, and I agree it's certainly one of the hardest to learn. For a programming course that's about concepts (such as "usable interfaces"), you probably don't want problems with the language get in the way of the students. After a student has the concepts down pat, it's easy to write them in a different language, even an unwieldy monster such as C++.

    For alternatives, check out Objective-C or Smalltallk (maybe even Java) sometime. They're both excellent languages for learning object-oriented programming, and the language doesn't get in your way (maybe Smalltalk even less than ObjC). Once the students have understood what OO and good GUI programming is all about, they can always learn C++ if they feel the need. It's only a language. But be warned, they'll probably balk at C++ once they've seen how nice a language can be.

    Fourth, C++ compilers (especially gcc) have improved a lot during the last couple years.

  32. Re:wow! we are at the python/java/.NET era! by master_p · · Score: 2, Funny

    And programming, generally, is ...so sixties!!! (where is my AI bot to write programs for me ?)

  33. Re:Gah! Kill Qt already! by cozziewozzie · · Score: 2, Interesting

    How is Qt's licensing abysmal, please? It's licensed under the GPL. Just like Linux, GNU, GCC, Emacs, MySQL, MPlayer, The GIMP, and just about any other Free Software program.

    So, what's so abysmal about the GPL? You sound like you think the world would be much better off if Linux, GNU, GCC, Emacs etc. all changed to proprietary licensing (like "WindowsXP from NewEgg") and available for "less than $100 from NewEgg".

  34. Re:Gah! Kill Qt already! by Umrick · · Score: 2, Informative

    I've never understood this argument. In a corporate developement environment, $2400 is trivial, especially if it nets you cross-platform, integrated DB access, and a host of other base capabilities.

    In the land of $100k for a DB, $70k servers, etc, $2400 is nothing. Now if you want to make the case that $2400 is too steep for a single developer, I've spent that much for Enterprise versions of JBuilder. Maybe it's too much for a shareware developer, or a budget strapped startup, but it's certainly not out of reach.

  35. Re:Gah! Kill Qt already! by JCholewa · · Score: 2, Interesting

    > Oh, and there is no GPL version for Windows

    As a matter of fact, there is.

    Trolltech has no impetus or obligation to port GPL Qt to Win32. But GPL is GPL, so anybody with enough skill can -- and did -- port the codebase to MS Windows. Yeah, it's not perfect (yet), but I've compiled and run stuff written in Qt2.3NC with this GPL'd version of Qt3.x.

    --
    -JC
    coder
    http://www.jc-news.com/parse.cgi?coding/main

    PS: It's Windows-native and doesn't need X11 to run, in case you're confusing it with the similar project on the same sourceforge area.