Qt中实现图片透明度设置与显示

drawForeground(QPainter *painter, const QRectF &rect)  
{  
    QPixmap foreImg;  
    foreImg.load("C:/Users/Desktop/fengjing1.jpg");  
    if (!foreImg.isNull())  
    {  
    painter->setOpacity(0.4);//透明度设置  
    painter->drawPixmap(int(sceneRect().left()), int(sceneRect().top()), foreImg);     
    }  

}  
drawBackground(QPainter *painter, const QRectF &rect)  
{  
    QPixmap foreImg;  
    foreImg.load("C:/Users/Desktop/fengjing2.jpg");  
    if (!foreImg.isNull())  
    {  
    painter->setOpacity(0.9);//透明度设置  
    painter->drawPixmap(int(sceneRect().left()), int(sceneRect().top()), foreImg);     
    }  
}