Qt设置背景图片

window.setAutoFillBackground(true);

    QPalette palette = window.palette();
    palette.setBrush(QPalette::Window,
            QBrush(QPixmap("background.jpg").scaled(// 缩放背景图.
                window.size(),
                Qt::IgnoreAspectRatio,
                Qt::SmoothTransformation)));             // 使用平滑的缩放方式
    window.setPalette(palette);

猜你喜欢

转载自www.cnblogs.com/QiLF/p/9427899.html