Reputation: 332
I searched all over the internet for a solution for this, but found nothing. Basicly I have a QLineEdit name 'le' (inside a class) whose background I want to set as an image. Using the code bellow, i get the error "Could not parse stylesheet of widget 0x1867580" and the image is not dispalyed.
self.le = QtGui.QLineEdit(self)
self.le.move(300,300)
self.le.setFrame(False)
self.le.setFixedWidth(100)
self.le.setStyleSheet("background: url:(Try.png)")
The Try.png image is a 100x20 px image, so it was supposed to fit that particular QLineEdit. Does anyone have a clue about what might be going on?
Many thanks in advance,
Miguel
Upvotes: 1
Views: 748
Reputation: 29463
Try
self.ls.setStyleSheet("background-image: url(Try.png);")
but Try.png must be in folder from which Qt app started. Unless it is a resource, then
self.ls.setStyleSheet("background-image: url(:/images/try);")
where images is name of resource group
<qresource prefix="/images">
<file alias="try">Try.png</file>
</qresource>
then the image will be compiled into the app.
Upvotes: 1