Hi, I have a window with a Qwt barchart and I need to display a background image that fills all the window.
The best I could get was:
img.JPG
As you can see, the image isn't displayed correctly. I've overridden MainWindow's resizeEvent() method this way in main.c:
{
QPixmap bkgnd
(":/files/image.png");
bkgnd = bkgnd.scaled(this->size(), Qt::IgnoreAspectRatio);
palette.
setBrush(QPalette::Background, bkgnd
);
this->setPalette(palette);
}
void MainWindow::resizeEvent(QResizeEvent*)
{
QPixmap bkgnd(":/files/image.png");
bkgnd = bkgnd.scaled(this->size(), Qt::IgnoreAspectRatio);
QPalette palette;
palette.setBrush(QPalette::Background, bkgnd);
this->setPalette(palette);
}
To copy to clipboard, switch view to plain text mode
And commented in barchart.cpp:
//setAutoFillBackground( true );
//setPalette( Qt::white );
//canvas()->setPalette( QColor( "LemonChiffon" ) );
//setAutoFillBackground( true );
//setPalette( Qt::white );
//canvas()->setPalette( QColor( "LemonChiffon" ) );
To copy to clipboard, switch view to plain text mode
The original image is:
image.png
Using bkgnd = bkgnd.scaled(this->size(), Qt::KeepAspectRatioByExpanding); produces the same output.
How can I solve it?
Bookmarks