C++ GUI Programming with Qt 3
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.
ConclusionThis 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.
GTK Tutorial
QT Tutorial
-------
Chunky Bacon
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!
Tutorial #2
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
Never underestimate the dark side of the Source
programming GUI in C++... it's so nineties!!
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.
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!
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!
...review everywhere!
Timeo idiotikOS et dona ferentes
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.
Who doesn't like free music?
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.
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.
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...
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/
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.
... is give these guys a hand up: QT 3 Win32- this project would be totally awesome would it be done!
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?
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.
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...
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
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...
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.
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.
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.
Thanks
Bruce
Bruce Perens.
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...
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!!!
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
If you already know C++, then it might be a good idea to check out the Independent Qt Tutorial.s /qt_tutorial/
http://www.digitalfanatics.org/project
(but without those spaces in the URL)
Because you are a coward?
How awfully nice for you. May we therefore assume that you're more clever than the rest of us?
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]?
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?
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?
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
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.
And programming, generally, is ...so sixties!!! (where is my AI bot to write programs for me ?)
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".
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.
> 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.