Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set QPalette back to default system palette?

I start my application initially in a dark color theme according to this example.

I would like to make possible for users, to switch back to their current default system color profiles of their operating system (as I start that application without setting QPalette). Is that posssible?

like image 501
Ralf Wickum Avatar asked Dec 20 '22 01:12

Ralf Wickum


1 Answers

One possible way is just use default settings and parameters:

void MainWindow::on_pushButton_clicked()
{
    qApp->setPalette(this->style()->standardPalette());
    qApp->setStyle(QStyleFactory::create("WindowsVista"));
    qApp->setStyleSheet("");
}

But this way has some limitation: we need some QWidget for setting palette, in my way I use this poiter to QMainWindow, however it is not so serious problem i think.

like image 85
t3ft3l--i Avatar answered Dec 28 '22 06:12

t3ft3l--i