在我的程序中,我正在滚动区域中显示我的tif图像,但是查看图像的一部分并不清楚。我尝试了多种方法,但我仍采用相同的方法。谁能告诉我如何在滚动区域中清晰显示图像?
下面是我的代码:
import sys
from PyQt4 import QtCore, QtGui
class Settings(QtGui.QMainWindow):
def __init__(self, parent=None,username='',password='',user=''):
super(Settings, self).__init__(parent)
self.newwidget = QtGui.QWidget()
self.mainLayout = QtGui.QVBoxLayout(self.newwidget)
self.scrollArea_right = QtGui.QScrollArea(widgetResizable=True)
self.scrollArea_right.setWidget(self.newwidget)
self.setCentralWidget(self.scrollArea_right)
# self.centralWidget().setLayout(self.mainLayout)
print self.scrollArea_right.viewport().width(),self.scrollArea_right.viewport().height()
self.lb = QtGui.QLabel()
self.mainLayout.addWidget(self.lb)
myPixmap = QtGui.QPixmap("/home/cioc/Desktop/Sample/DIR001/SH000003.tif")
myScaledPixmap = myPixmap.scaled(638,478, QtCore.Qt.KeepAspectRatio)
self.lb.setPixmap(myScaledPixmap)
self.lb.setScaledContents(True)
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
w = Settings()
# w.resize(500,500)
w.show()
sys.exit(app.exec_())