QLabel大小未在QGraphicsScene规模上更新

时间:2015-10-25 22:02:36

标签: python qt pyqt qt4

我想在pyqt中使用QGraphicsViewQLabel垂直显示一些图像。

我正在使用scale方法进行缩放QGraphicsView。问题是当我缩放(放大)QGraphicsView标签大小没有更新时,因此当我缩放QGraphicsView并再次设置标签的像素图时,导致图像质量很差。

这是我的代码:

my_graphics_view = QtGui.QGraphicsView()
scene = QtGui.QGraphicsScene()
graphics_widget = QtGui.QGraphicsWidget()
layout = QtGui.QGraphicsLinearLayout(QtCore.Qt.Vertical)
default_size = QtCore.QSize(400 , 400)
for number in xrange(num_pages):
    lbl = QtGui.QLabel()
    lbl.setMinimumSize(default_size)
    lbl.setStyleSheet("background-color : white")
    lbl.setContentsMargins(0, 0, 0, 0)
    lbl.setScaledContents(True)
    widget = scene.addWidget(lbl)
    layout.addItem(widget)
graphics_widget.setLayout(layout)
scene.addItem(graphics_widget)
my_graphics_view.setScene(scene)
my_graphics_view.show()

0 个答案:

没有答案
相关问题