set backgorund image on main window
i have a problem to set a background image on main window. i discovered that qt can use css to give some appearance. for my application i have created the image and put in into folder name image in source code folder. i have successfully code the css syntax
Code:
QWidget#centralwidget { background-image: url(:/image/mainbg2.png); background-repeat: repeat-x; }
when I click apply there nothing happen on my main window. my question here is does this thing work on the spot or we need to compile first to see the result?
Re: set backgorund image on main window
Yes, you need to recompile, because the resource will be compiled and embedded in the application. And how else would you be able to set a stylesheet for a widget without setStylesheet and recompiling?
Re: set backgorund image on main window
owh... actually I used qt designer and I did set the style through it. Pardon the code I've paste before. Its a wrong code to be put into through designer, Ive fixed it.
Now I have some more question, do we need to put the image file into resource (.qrc file)?
Re: set backgorund image on main window
Just add a reference to it(it's path). It will be embedded in the application at compile time.