Solved Change background color of QPushButton at runtime
-
Hello, I need to change a background color of QPushButton during execution, so I created this StyleSheet:
QPushButton { background-color:rgb(255, 255, 255); font-weight:bold; font-size:24px; color:#000; } *[class=active] { background-color:rgb(255, 0, 0); font-weight:bold; font-size:24px; color:#000; }
and in code I call:
ui->pushButton_Click->setProperty("class", "active");
But it works only if it is in
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
function, if I call it in my custom function it doesn't work.
-
Hi,
Are you applying the technique described in this Wiki entry ?
-
This post is deleted! -
@SGaist thank you so much, it works, I forgot to use unpolish and polish.