I have the problem that the background of the button cannot be changed. Only the border is changed. I assumed that some attribute prevented this. But I think I'm wrong on that point. I've gone through the Qt documentation but can't find anything. I can only find examples on the internet that give me the same result. Is there a way to change the background?
Here is the code:
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
//ui->pushButton->setAttribute(Qt::WA_SetPalette);
//ui->pushButton->setAttribute(Qt::WA_SetStyle);
ui->pushButton->setAutoFillBackground(true);
ui->pushButton->setAttribute(Qt::WA_ShowModal);
QPalette pal = ui->pushButton->palette();
//pal.setColor(QPalette::Base, Qt::cyan);
//pal.setBrush(QPalette::Base, Qt::cyan);
pal.setColor(QPalette::Button, Qt::cyan);
pal.setBrush(QPalette::Button, Qt::cyan);
ui->pushButton->setPalette(pal);
ui->pushButton->update();
//ui->pushButton->setAttribute(Qt::WA_NoSystemBackground, true);
// setAutoFillBackground(true);
// QPalette pal2 = palette();
// pal2.setBrush(QPalette::Button, Qt::cyan);
// pal2.setColor(QPalette::ButtonText, Qt::cyan);
// QApplication::setPalette(pal2);
}