Have a look at the file qglobal.h in the Qt sources for Q_DECLARE_PRIVATE and Q_D macros then revisits the QLineEdit sources.
A beginners guide to hacking Qt? Not that I am aware of. Hacking Qt library sources in anything but the most trivial way is not a beginner's domain. You start with Qt Assistant, the code, online resources, and good deal of inquisitiveness when faced with some thing you don't immediately follow. You will need to walk before you can run. Chances are that in the process of learning you will discover you don't need to modify the Qt sources anyway.