MyScrollArea.viewport().setStyleSheet(\ "background-image: url(/myImage.png); "\ "background-attachment: fixed; "\ "background-repeat: no-repeat; "\ "opacity: 100" \ )
def setBackGround_image(self, image_path): p = QtGui.QPalette() pixmap1 = QtGui.QPixmap(image_path) rect = QtCore.QRect(self.geometry()) size = QtCore.QSize(rect.width() , rect.height()) pixmap = pixmap1.scaled(size) p.setBrush(QtGui.QPalette.Background, pixmap) self.setPalette(p)
C++ (Qt)QPainter p( &pixmap1 );p.fillRect( pixmap1.rect(), QColor( 255, 255, 255, 127 ) );