https://zhuanlan.zhihu.com/p/32134728
主要是使用Qlabel来实现
获取宽度:Qlabel.width()
获取高度:Qlabel.height()
def cut(self):
screen = QApplication.primaryScreen()
# pix = screen.grabWindow(self.window.winId())
pix = screen.grabWindow(self.img_label.winId())
pix.save("test.jpg")
图片太大的解决方法:
self.scrollArea = QtWidgets.QScrollArea(self.centralwidget)
self.scrollArea.setGeometry(QtCore.QRect(20,60,841,591))
self.scrollArea.setWidgetResizable(True)
self.scrollArea.setObjectName("scrollArea")
self.MyScroll = QtWidgets.QWidget()
self.MyScroll.setGeometry(QtCore.QRect(0,0,839,589))
self.MyScroll.setObjectName("MyScroll")
self.MyScroll.setMinimumSize(7000,7000)
#scrollArea就对了
图片控件(QImage)
def pic(self):
# print(self.window.size)
pix = QPixmap('icon/123.png')
scale=1
print(pix.width())
if pix.width()
self.img_label.setGeometry(10,10,pix.width()*scale,pix.height()*scale)
else:
self.img_label.setScaledContents(True)
# self.img_label.setGeometry(10, 10, self.width*scale, self.height*scale)
self.img_label.setStyleSheet("border: 2px solid red")
self.img_label.setPixmap(pix)
# self.img_label.mouseDoubleClickEvent(self.zoom())
网友评论