qt QPixmap適應QGraphicsView大小

QGraphicsView* ViewPath   = new QGraphicsView(this);
ViewPath->setGeometry(0,0,450,600);
QGraphicsScene ScenePath;
ViewPath->setScene(&ScenePath);
QImage  img_path_disp=img_path_disp.scaled(ViewPath->width(), ViewPath->height(), Qt::IgnoreAspectRatio);
QGraphicsPixmapItem *p=ScenePath.addPixmap(QPixmap::fromImage(img_path_disp));
ViewPath->fitInView(p, Qt::IgnoreAspectRatio);
ViewPath->show();

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章