#include class MyDialog : public QDialog { Q_OBJECT public: MyDialog(QWidget *parent = 0) : QDialog(parent), isRed(false) { b1 = new QPushButton("b1"); //b1->setAttribute(Qt::WA_NativeWindow, false); b2 = new QPushButton("b2"); b3 = new QPushButton("b3"); QVBoxLayout *vl = new QVBoxLayout(this); vl->addWidget(b1); vl->addWidget(b2); vl->addWidget(b3); int siz = 25; b3->setFixedHeight(siz); b3->setFixedWidth(siz); connect(b1, SIGNAL(clicked()), this, SLOT(changeColor())); connect(b2, SIGNAL(clicked()), this, SLOT(changeColor())); connect(b3, SIGNAL(clicked()), this, SLOT(changeColor())); } protected slots: void changeColor() { if (!isRed) setStyleSheet("QDialog {background-color:red;}"); else setStyleSheet("QDialog {background-color:blue;}"); isRed = !isRed; } private: QPushButton *b1, *b2, *b3; int isRed; }; #include "main.moc" int main(int argc, char *argv[]) { QApplication a(argc, argv); MyDialog w; w.show(); return a.exec(); }