def paintEvent(self, _): """ Called when the widget is painted on the window. """ painter = QPainter(self) # Paint the text first map = painter.deviceTransform().map self._textWidget.render(painter, map(QPoint(0, 0))) # Then paint the icon current = self._textWidget.sizeHint().width() + 3 self._iconWidget.render(painter, map(QPoint(current, 0)))