PDA

View Full Version : Qt Designer Transparent Image Background Color Issue



CrispyBoardgames
8th June 2021, 23:03
I'm building a simple screen. I've added a couple of layouts to organize it. Like so: https://imgur.com/a/61mqDBp
I changed the MainWindow's background to an image through the styleSheet property


background-image: url(:/MainBackground/MM_Main_Background.png);\nbackground-color: transparent

The transparent line was an attempt to fix the issue. Doesn't change anything.

I then added three objects to the top horizontal layout
- a Label
- a lineEdit
- a Label
I used pixmap and added an image to both labels. Both of the images have transparent backgrounds. I was expecting the images to have the correct background color based on their location, but it seems that they keep the color of the background's left side. I've tried changing their properties to be transparent, changed centralWidget and MainWindow's colors but no dice. I did this based on my Google search results but I have not found something concrete/similar to my problem. I'm probably not searching well enough but I don't know how to best word my problem.

Thanks in advance to anyone that reads this.

13650

CrispyBoardgames
9th June 2021, 20:28
For anyone that has a similar problem. The solution was the following: use styleSheet instead of pixmap. When you add the image, make it a background image not just a normal image. If you had an empty label with no text, this might make the label 'disappear.' Change the sizePolicy to minimum and change the minimumSize to what you need.

rizarefaldi
19th July 2021, 20:41
For anyone that has a similar problem. The solution was the following: use styleSheet instead of pixmap cara install windows 10 (https://itkoding.com/cara-install-windows-10/)
When you add the image, make it a background image not just a normal image. If you had an empty label with no text, this might make the label 'disappear.' Change the sizePolicy to minimum and change the minimumSize to what you need.

Why we have to use styleSheet? my source is only pixmap