Problem with central widget and style sheet
-
Hello, i have a problem
you can see the problem in the videos below, in the first video i don't set style sheet to my central widget
http://ubuntuone.com/3dly9V6LCwPBWMjnMYxcdr
in the second video i set style sheet to my central widget
http://ubuntuone.com/4lyf6EEaAmWL8DWS6N44Gi
the style sheet i set is a backgound image
@QWidget#mainwidget {
background-image: url(/home/chris/.config/coyote/themes/dark/images/general_background.png);
}@i have set mainwidget as ObjectName to the widget
the problem as you can see is that when i set style sheet the other styles sheets at the other widgets doesn't change
also the background of the central widgets doesn't change accordind to the imageany idea?
-
Your way won't working. If you use Qt Designer - you can select centralWidget and add dynamic value to it (green cross at Object Inspector topbar) with bool value - true. And in your .qss:
@
QWidget[somevalueiaddedbefore=true] {
background-image: url("/home/chris/.config/coyote/themes/dark/images/general_background.png");
/* or /
background-image: url(":/themes/dark/images/generalBackground.png"); / qrc-way */
}
@
But I recommend you to use resources instead of full way (like the second way). Read about resources on the Net.UPD: Or you can do simply, just use objectName as ID:
@
QWidget#centralWidget {
background-image: url("/home/chris/.config/coyote/themes/dark/images/general_background.png");
}
@ -
My suggestion would be to get other forms of a stylesheets working on your central widget first...go to the designer, click on your central widget in the object list, and click the stylesheet interface. Add this line:
@
#centralWidget {
color: rgb(85, 255, 0);
}
@or if its name is mainWidget then
@
#mainWidget {
color: rgb(85, 255, 0);
}
@See if your button text colors changes...if so, then its something wrong with your stylesheet command. I just tried it and it worked for me.
-
with the color it works
so there is a problem with my style sheet, hmm, i tried moving my image in the project's folder but nothing
just a correction, for the backgound color the style sheet needs to be
@#centralWidget {
background-color: rgb(85, 255, 0);
}
@ :)