I explored various examples of QPainter wherein it is used by separate classes to draw objects. I wish to use QPainter in the Mainwindow itself to draw rectangles. Is it possible to do so? If yes, Can anyone help me with it?