c++ - How do I stop Qt's setStyleSheet from resetting designated colors on my form and buttons? -


so i've got 152 qpushbuttons in program. each button represents item , each item has color designating status. code below colors right button when asked user input, however, when code colors specific widget, resets other styles have on form. reset includes buttons colored code. how stop this?

here simplified 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); } 

you should set stylesheet exact button need tweaked, instead of apply style it's parent form:

qstring buttonname = qstring("shelf%1").arg(input); qpushbutton* button = this->findchild<qpushbutton*>(buttonname); button->setstylessheet(stylestring) 

Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -