Debugging code is always a pain in the neck, but there's a tiny new utility in
kdesdk which might make things a little less stressful. The utility, KSpy, gathers information about the state of a running KDE application and
displays it graphically. Read more below.
The core of KSpy is a tiny library which displays a tree of all the QObjects in
an application. Selecting an object allows you to view its properties, and the
signals and slots it defines. This information is already available to
developers via the Qt methods QObject::dumpObjectTree()
but their output is not particularly convenient (and sends a lot of messages to
the console if you forget to remove it!). KSpy has only minimal overhead for the
application, as the kspy library is loaded dynamically using KLibLoader.
You can see a picture of the KSpy probing it's own test program in this screenshot.
To use KSpy from your code, first build and install kdesdk/kspy, include the
header kspy.h, and finally call KSpy::invoke() when you want to run the probe.
You can easily wrap this call in a slot so it can be bound to a keystroke or an
action. In the future, KSpy will probably gain a few more abilities such as the
ability to watch the events an object receives and the ability to see which
config files are in use, but it should be pretty useful already.
While you're looking at KSpy, you should check out some of the other goodies in
kdesdk - this module has a whole host of tools for developers:
A tool for application translators which makes it easy to edit .po files.
A script that can generate the basic framework for a KDE application.
A memory leak hunting tool.
A tool for measuring app startup times.
Scripts for tasks such as packaging an app from CVS, updating your local copy
of KDE and more.