Could not make background image not to repeat
-
I am puzzled why it did not use background-repeat to no-repeat. It kept appearing repeating in the both directions. Maybe you could catch something that I overlooked. Basically this works as background image and I was able to put controls over the image. I just need the image to be non-repeat.
Here is the code as follows:class displayImage(QtWidgets.QDialog):
def init(self,parent=None):
super(displayImage, self).init()self.setGeometry(50,50,25,250) oImage = QtGui.QImage("C:/imagefilename.bmp") self.setStyleSheet("background-image: url(oImage); background-repeat: no-repeat; background-position: left;") # sImage = oImage.scaled(QtCore.QSize(75,250)) # resize Image to widgets size palette = QtGui.QPalette() palette.setBrush(QtGui.QPalette.Window, QtGui.QBrush(oImage)) self.setPalette(palette)
-
@autoasl
Qt as a framework, comes in many different versions. (Also as bindings for python)you can simply print QT_VERSION to check at run time, I don't know how else you would check it as I'm not familiar with Python.
something like this:int main(int argc, char *argv[]) { QApplication a(argc, argv); qDebug() << QString::number(QT_VERSION,16); // Result will be 50C06 -> Qt 5.12.6 return a.exec(); }
I'm asking, because there was a bug with stylesheets, and those were not correctly applied to the widgets. That was fixed in the newest versions, 5.12.6 and 5.13.2
-
@autoasl said in Could not make background image not to repeat:
PySide2
Interesting, from the official side, it should be 5.12.6 🤔
https://pypi.org/project/PySide2/I however, can not further help you, I'm sure someone else has more experience with Images as background Brush :)
-
@J-Hilk Thank you for pointing out what is the root cause. I'll try investigating more. I see one from the Internet "Maya 2019 uses Qt5.6.1 which is binary compatible with the latest version of PyQt 5.11.3 / SIP - 4.19.13" I may need to try upgrade if I can