WesleyRodrigues
WesleyRodrigues

Reputation: 63

Stylesheet QmainWindow does not work on pyqt5, only qt designer preview

stylesheet Qt designer:

QMainWindow {
                
    background-image: url(:/tela/app_imagens/kawaii-1546834.png);
                background-repeat: no-repeat; 
                background-position: center;
 }

In the preview of the qt designer the stylesheet works normally:

qt

however when running the application nothing appears:

app

Upvotes: 1

Views: 314

Answers (1)

eyllanesc
eyllanesc

Reputation: 244301

What happens is that Qt Designer compiles the .qrc and imports it unlike your script which does not. The solution is:

  1. Compile the .qrc:
pyrcc5 file.qrc -o file_rc.py
  1. and import it into your .py:
import file_rc

Upvotes: 3

Related Questions