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
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.
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!
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.
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
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.
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.
What I'm listening to now on Pandora...
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...
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
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
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...
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
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
Thanks
Bruce
Bruce Perens.
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
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)
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++.
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.
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.