I am creating an Error Message Box for my Screen. I am using QDialogButtonBox for buttons. Now i want to fill Buttons with different colors. For example: "OK" --> Green "Cancel" --> Red etc. I am able to change the background for all buttons , but not individually.
Is there any way to do this ??
Thanks in advance !!!!
Try this(using QDialogButtonBox::button() and QPushButton::setStyleSheet()).
QDialogButtonBox* buttonBox = new QDialogButtonBox;
// set up your button box
QColor okButtonColor = Qt::red;
buttonBox->button(QDialogButtonBox::Ok)->setStyleSheet(QString("background:%1").arg(okButtonColor.name()));
EDITED: typo fixed in code around building style sheet string.