QPainter painter(this); QRect rect(100, 100, 50, 50); painter.drawRect(rect);
QImage image("image.png"); QPainter painter(this); painter.drawImage(0, 0, image);
QPainter painter(this); painter.setFont(QFont("Arial", 12)); painter.drawText(QRect(0, 0, 100, 100), "Hello world!");This code sets the font for the painter and draws the text "Hello world!" inside a rectangle with a top-left corner at (0, 0) and a width and height of 100 pixels. The QPainter class is part of the Qt GUI module, which is included in the Qt library.