PDA

View Full Version : Changing QMainWindows backgroundcolor



dennis81
9th October 2012, 10:27
Hi,

I want to change the backgroundcolor of QMainWindow.
setStyleSheet("QMainWindow {background-color: #000000}"); changes the background color of menubar, but not of the centralwidget.
QMainWindow::centralWidget(); returns a NULL-Pointer.

Is there a special stylesheet tag for the empty centralwidget area?

sonulohani
9th October 2012, 10:33
MainWindow->setStyleSheet("background-color: rgb(0, 0, 0);");

dennis81
9th October 2012, 10:47
MainWindow->setStyleSheet("background-color: rgb(0, 0, 0);");

It does not affect the central widget. It is still gray :-(

anupam
9th October 2012, 12:32
Try to use setpallete()

Added after 14 minutes:

Try to use setpallete()

dennis81
10th October 2012, 12:12
The solution is to set a centralwidget and change its background: :cool:

setCentralWidget(mMdiArea);
QBrush backBrush;
backBrush.setTexture(QPixmap(":/background.png"));
mMdiArea->setBackground(backBrush);