0
Could not parse stylesheet of object 0x2d956381ba0

enter image description here

   def change_btn_image(self, btn):
    imagem = self.atv_imagens_bd[self.atividades.get_contador()]
    nome_imagem = imagem[:-4]
    print(nome_imagem)

    btn.setStyleSheet(f"border-image: url(src/main/resources/base/{imagem});")
    return nome_imagem
eyllanesc
  • 235,170
  • 19
  • 170
  • 241

1 Answers1

1

As explained in a slightly related answer, HTML (and, therefore, stylesheet) parsing capabilities of Qt are a bit limited if compared to web browser parsers.

While those syntax are somehow pretty "liberal", one shouldn't push the boundaries of their freedom too much: it's always good practice to use quotes for string based values (besides keywords, obviously), most importantly for URLs.

In this case, the problem is the utf character, which creates a problem as the parser is unable to correctly identify where the url ends.

Just add quotes around the url path:

btn.setStyleSheet(f"border-image: url('src/main/resources/base/{imagem}');")
musicamante
  • 41,230
  • 6
  • 33
  • 58