Suggested code changes
Use a QMainWindow. That's what they're for. The example
will work, but using a QDialog as your app's main widget is
not good practice.
example1Dialog should be renamed Example1Dialog, to
match the Qt naming convention. Names of classes,
structs, enums and constants start with a capital letter.
Names of variables and methods start with a lowercase
If you use Example1Dialog as the name, then you can do
this, with no ambiguity:
It's common practice to name slots with a prefix, to remind
you that they're slots. For example, slotFooClicked().
All user-visible strings should be wrapped in tr() for future
You call vb->setAutoAdd with a pointer to a QVBoxLayout
as its parameter. setAutoAdd takes a bool parameter. Your
code will work, but this is bad form. You're relying on the
fact that pointers auto-convert to bool. Use bool to avoid
confusing people reading your code and to ease future
porting to another language.
Don't elide variable names. pbFoo should be called
pushButtonFoo. You might know your own naming
convention, but when I come to read your code later and
I'm halfway down a source file, I'm going to have to check
back to see what the pb prefix means.
There's a typo in your CONFIG line (in your .pro file) - it
should be warn_on, not want_on.
As a general comment, this is a disappointingly short, badly
written, badly thought out article. I'm a big fan of Qt, using
it all day every day for commercial and free projects. A
pointer to the Qt signals and slots documentation would
have been worth much more than this article, I'm afraid.
Qt comes with SAX and DOM parsers. You get a proper C++
object model to play with. It's all value based, so very easy to
handle - no pointers to mess with. Strings are stored as
QString objects, which are implicit shared and store 2 byte
Doing my bit to enlighten those who think Qt is just a GUI