Qwidget显示图片

QWidget显示图片

void paintEvent(QPaintEvent *event)
{
    QPainter p;//创建画家对象
    p.begin(this);
    QPixmap tempPixmap = QPixmap::fromImage(img1,Qt::AutoColor);

    int w1 = img1.width();
    int h1 = img1.height();
    p.drawPixmap(0, 0, w1, h1, tempPixmap);
    
}

 

 

 

####################

posted @ 2022-03-22 21:14  西北逍遥  阅读(877)  评论(0编辑  收藏  举报