QWidget background-image not showing-up
-
Hi community !
I have a question, it might be stupid but ... I have an issue with that.
I have created a QWidget inside Qt designer and tried to set the styleSheet as following:QWidget {background-image: url(:/corp/home/name/maya/scripts/image.jpg)}
But nothing it displayed ... I have seen that there is a question of relative/absolute path depending if you're working with the Qt project or not which I am not using. By not using it, it is logical that I use an absolute path to my file... So I don t get why this is not working... Am I missing something ?
Thx
-
Hi
I thinks its the ":" in the paths. that is normally used when loading from a qrc file.this works for me
QWidget {
background-image: url(e:/test.png)
}
with image on E:That said, using absolute path will come back and haunt you if you ever want to run the app elsewhere than on your pc. :)
-
Oh Thank you, it s working without ":" but I now realize that it's not what I want as the image is tiling... I just want to display it as 1 image.
I guess I will go back to the QLabel + pixmap but then it is not very convenient as you can't put items on top like you would do if it was a QWidget background.absolute path was for testing purpose, then this will be integrated into a pipeline and and point to a relative path.
-
Oh Thank you, it s working without ":" but I now realize that it's not what I want as the image is tiling... I just want to display it as 1 image.
I guess I will go back to the QLabel + pixmap but then it is not very convenient as you can't put items on top like you would do if it was a QWidget background.absolute path was for testing purpose, then this will be integrated into a pipeline and and point to a relative path.
-
Is there a way to center the image in the QWidget ? apparently you can only specify what corner you want it to be but that's all.
Edit:
Okay after further tests, I don' t want to use the background-image because if I add an other widget in this QWidget it wil have the image displayed too. Or maybe there is a way to specify that we want to display it for this QWidget only and not his children ?
-
Is there a way to center the image in the QWidget ? apparently you can only specify what corner you want it to be but that's all.
Edit:
Okay after further tests, I don' t want to use the background-image because if I add an other widget in this QWidget it wil have the image displayed too. Or maybe there is a way to specify that we want to display it for this QWidget only and not his children ?