PDA

View Full Version : Background color



FelixB
28th January 2011, 11:31
Hi,

I want to change the background color of a QwtPlot. The method "setCanvasBackground" changes only the background color of the canvas. How can I change the color "under" the scales and the labels (this is normally gray)?

I tried the following snippet with no effect...


QPalette p = plot->palette();
p.setColor(QPalette::Window, background);
plot->setPalette(p);

if I remove "plot->" in the snippet, it works for my whole widget (including toolbar and statusbar). How can I change the color only in QwtPlot widget?

thanks!
Felix

Uwe
28th January 2011, 12:07
plot->setAutoFillBackground( true );
QPalette p = plot->palette();
p.setColor(QPalette::Window, background);
plot->setPalette(p);

Uwe

FelixB
28th January 2011, 12:58
thank you!

mqt
22nd June 2013, 06:53
That was not helpping to make entire plot (including label background) white. Following code helpped me. But still I am getting a shadow line at left and top. Is there a way to get rid of that also?


setCanvasBackground(QColor(Qt::white));
setStyleSheet("background-color:white;");

Uwe
24th June 2013, 07:03
plot->setAutoFillBackground( true );
plot->setPalette( Qt::white );
plot->setCanvasBackground( Qt::white );

QwtPlotCanvas *canvas = dynamic_cast<QwtPlotCanvas *>( plot->canvas() );
canvas->setFrameStyle( QFrame::NoFrame );Better don't use style sheets for silly operations like this one. In rare situations they might have a negative impact on the performance ( full repaints instead of partial updates ) - and of course they are conflicting with the concept of palettes.

Uwe