Background image
-
How can I made background image? I use some thing but it doesn't help
import sys from PyQt5 import QtCore, QtGui, QtWidgets class ClassesPage1(QtWidgets.QWizardPage): def __init__(self, *args, **kwargs): super(ClassesPage1, self).__init__(*args, **kwargs) self.setTitle("...") self.setSubTitle("...") #self.setStyleSheet("background-color: rgb(100, 133, 202);") self.checkBox_1 = QtWidgets.QCheckBox('...') self.checkBox_2 = QtWidgets.QCheckBox('...') self.checkBox_3 = QtWidgets.QCheckBox('...') self.checkBox_4 = QtWidgets.QCheckBox('...') self.layout = QtWidgets.QVBoxLayout() self.layout.addWidget(self.checkBox_1) self.layout.addWidget(self.checkBox_2) self.layout.addWidget(self.checkBox_3) self.layout.addWidget(self.checkBox_4) self.setLayout(self.layout) self.checkBox_1.stateChanged.connect(self.check) self.checkBox_2.stateChanged.connect(self.check) self.checkBox_3.stateChanged.connect(self.check) self.checkBox_4.stateChanged.connect(self.check) self.listCheckBox = [self.checkBox_1, self.checkBox_2, self.checkBox_3, self.checkBox_4] self.a = 0 def check(self, state): self.a = 0 if state == Qt.Checked: a = a + 1 for checkBox in self.listCheckBox: if checkBox.isChecked(): self.a += 1 print(self.a) def nextId(self): return Wizard.class4 stylesheet = ''' QWidget { background-image: url("C:\111.jpg"); } ''' if __name__ == '__main__': app = QtWidgets.QApplication(sys.argv) app.setStyleSheet(stylesheet) w = ClassesPage1() w.show() sys.exit(app.exec_()) -
Hi,
@sashup said in Background image:
background-image: url("C:\111.jpg");
The path is invalid. You are escaping the 1 with that backslash.
Either properly escape it or use forward slashes since Qt provides support for them on all platforms.Use forward slashes, it's the only variant that is supported in QSS.
-
Hi,
@sashup said in Background image:
background-image: url("C:\111.jpg");
The path is invalid. You are escaping the 1 with that backslash.
Either properly escape it or use forward slashes since Qt provides support for them on all platforms.Use forward slashes, it's the only variant that is supported in QSS.
-
Is the image file valid ?
-
You can check that it's valid by loading it in a QLabel.