0
votes

I'm using GUI form editor in qt creator, I have set the background

(right_click -> change_stylesheet->Add Resource -> background_image)

Then I added a few buttons, the buttons are colored like the background, instead of being normal - default. I was trying this with properties->palette but with poor results. I'm new to qt, so I am asking for your help.

1

1 Answers

2
votes

Like in CSS, Qt Style Sheet will apply your styling rules to any item that matches them.

If you just write:

background-image: url(:/my_background.png);

it will change the background of all the widgets in your application.

If you want to change the background of the main window only, you should write:

QMainWindow {
   background-image: url(:/my_background.png);
}

That will apply the background image only to the QMainWindow object.

For an detailed explanation of Qt Style Sheet, I invite you to read the official documentation here.