N
N
Nikita Yaremenko2021-01-19 18:43:01
PyQt
Nikita Yaremenko, 2021-01-19 18:43:01

How to display background image PyQt5?

There is a section of code that is responsible for the background image:

self.frame = QtWidgets.QFrame(self.centralwidget)
self.frame.setGeometry(QtCore.QRect(-1, -1, 973, 773))
self.frame.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))
self.frame.setStyleSheet("background-image: url(bg-01.jpg);")
self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame.setFrameShadow(QtWidgets.QFrame.Raised)
self.frame.setObjectName("frame")

Everything worked fine, after that I had to reinstall the OS, along with it, the python, I launch the project, and there is no picture. Displays the following message: Could not create pixmap from bg-01.jpg
The image is in the directory folder.
Tried to rollback PyQt5 version. Did not help.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question