Rui d'Orey
Rui d'Orey

Reputation: 1022

How to change the color of QWizard or QWizardPage background?

in Qt it is possible to specify the background color of QWizard Page?

Using setColor in QPallete::Base of the qApp of, if using a generic window, the background changes to the correct color.

However, if using a QWizard or QWizardPage, the background is set to white. Using

qApp->setStyleSheet("QWidget { color: #000000; background-color: #2a82da; border: 1px solid white; } ");

the color changes, but a lot of other elements also change to that color(all the widgets).

How is it possible to specify the color change to QWizard or QWizardPage?

Thanks in advance

Upvotes: 0

Views: 1435

Answers (3)

user10609288
user10609288

Reputation:

In Qt5 when you change background color.

  • QWizard - QPalette::Window - place near bottom buttons
  • qDebug()<< QWizardPage->backgroundRole(); get us QPalette::ColorRole(Window). But it's not true, real value is QPalette::Base

Code:

QPalette bgpal

bgpal.setColor(QPalette::Base, Qt::white);
setPalette(bgpal);
this->setAutoFillBackground(true);

`this->setBackgroundRole(QPalette::YourPalette)`; don't recommend to use, on olds Qt it has a bug.

P.S. Ye, it has the same role as lineEdit background and if you set to QLE border 0 you will get:

enter image description here

Upvotes: 0

Roya Ghasemzadeh
Roya Ghasemzadeh

Reputation: 691

I had the same problem and here is the solution.

Assume I have a child class of QWizard:

this->setObjectName("wizard");   
this->setStyleSheet("#wizard { background : #f4f7f9; ");

changes the wizard background color without affecting other elements.

Upvotes: 2

Rui d&#39;Orey
Rui d&#39;Orey

Reputation: 1022

Well, this seems to work:

QWizard wizard;
wizard.setStyleSheet("background-color:#E8E8E8");

Upvotes: -1

Related Questions