In my program, I have a total of 152 QPushButtons, with each button representing an item and having a color that indicates its status. The issue I'm facing is that when the code below colors a specific button based on user input, it also resets all other styles on my form, including buttons that were previously colored by the code. How can I prevent this from happening?
Below is the simplified version of the code:
QString input = QString(ui -> lineEdit -> text());
ui->lineEdit->clear();
int number = input.toInt();
if(status[number] == 1)
{
QString styleString = QString("#shelf"+input+"{background-color: rgb(0, 150, 255);}");
this->setStyleSheet(styleString);
}
else if(status[number] == 2)
{
QString styleString = QString("#shelf"+input+"{background-color: rgb(255, 0, 0);}");
this->setStyleSheet(styleString);
}
else if(status[number] == 3)
{
QString styleString = QString("#shelf"+input+"{background-color: rgb(0, 255, 0);}");
this->setStyleSheet(styleString);
}