painter = QPainter(self)
font = painter.font()
font.setPixelSize(48)
painter.setFont(font)
rectangle = QRect(0, 0, 100, 50)
boundingRect = painter.drawText(rectangle, 0, "Hello")
pen = painter.pen()
pen.setStyle(Qt.DotLine)
painter.setPen(pen)
painter.drawRect(boundingRect.adjusted(0, 0, -pen.width(), -pen.width()))
pen.setStyle(Qt.DashLine)
painter.setPen(pen)
painter.drawRect(rectangle.adjusted(0, 0, -pen.width(), -pen.width()))
