Your Qt distribution comes with a huge set of example programs, including many on painting widgets. Why don't you study those and understand how it works before trying to do something yourself?