PyQt graphicsView自适应显示图像

self.graphicsView.scene_img = QGraphicsScene()
self.imgShow = QPixmap()
self.imgShow.load(fileName)
self.imgShowItem = QGraphicsPixmapItem()
self.imgShowItem.setPixmap(QPixmap(self.imgShow))
#self.imgShowItem.setPixmap(QPixmap(self.imgShow).scaled(8000,  8000))    //自己设定尺寸
self.graphicsView.scene_img.addItem(self.imgShowItem)
self.graphicsView.setScene(self.graphicsView.scene_img)
self.graphicsView.fitInView(QGraphicsPixmapItem(QPixmap(self.imgShow)))    //图像自适应大小
posted @ 2020-04-14 11:12  willwuss  阅读(6895)  评论(0编辑  收藏  举报