用QImage的图片缩放功能,随着窗体大小的变化而进行缩放.
void MainWindow::on_stackedWidget_resized(int w, int h)
{
static QImage bg(":/image/welcome.jpg");
QPalette pal = pageWelcome->palette();
pal.setBrush(QPalette::Window,
QBrush(bg.scaled(w, h, Qt::IgnoreAspectRatio,
Qt::SmoothTransformation)));
pageWelcome->setPalette(pal);
}