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)))    //图像自适应大小


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM