PDA

View Full Version : How to change the color of background of QMainwindow?



weixj2003ld
5th July 2012, 11:56
When I create a QMainwindow only(that is ,there is no DockWidget,no central Widget),and the main area color is grey,how to change it to other color ,such as white?

Added after 8 minutes:

shows as picture.
7952

ChrisW67
5th July 2012, 12:26
QMainWindow m;
m.setStyleSheet("QMainWindow {background: 'yellow';}");
m.show();

Krump Lee
5th July 2012, 12:27
Did you try subclassing QMainWindow's paintEvent?

weixj2003ld
5th July 2012, 14:58
QMainWindow m;
m.setStyleSheet("QMainWindow {background: 'yellow';}");
m.show();


It can change the background color of QMainWindow,but it change the background color of Tool bar and status,too.


Did you try subclassing QMainWindow's paintEvent?

I have subclassed QMainWindow's paintEvent,but I'm sorry how to do in it?

wysota
6th July 2012, 00:56
What you want is to change the background of the centralWidget of the main window.