QPainter allows you to draw to any QPaintDevice subclass (typically QPixmap and QWidget). The most common usecase is to subclass QWidget, to reimplement the paintEvent() method and to use a QPainter to do custom painting.
Be aware that you cannot use QPainter to draw on a widget outside of its paintEvent() method!
Reimplementing various *Event() methods is "quite common":http://qt-project.org/doc/qt-4.8/QWidget.html#events in Qt, and is amongst others used for handling mouse events.
The "programming tutorial":http://qt-project.org/doc/qt-4.8/gettingstartedqt.html, the "QWidget":http://qt-project.org/doc/qt-4.8/QWidget.html#events and "QPainter":http://qt-project.org/doc/qt-4.8/QPainter.html#details documentation as well as the "examples":http://qt-project.org/doc/qt-4.8/painting-basicdrawing.html and freely available books like "C++ GUI Programming with Qt 4":http://www.qtrac.eu/C++-GUI-Programming-with-Qt-4-1st-ed.zip are a good place to start reading.