i want to show some images vertically using QGraphicsView and QLabel in pyqt.
i am using scale method for scaling QGraphicsView. the problem is that when i scale (zoom in) QGraphicsView size of labels not updating and because of that when i scale QGraphicsView and setting label's pixmap again resulting image quality is poor.
here is my code:
graphics_widget = QtGui.QGraphicsWidget()
layout = QtGui.QGraphicsLinearLayout(QtCore.Qt.Vertical)
default_size
= QtCore.
QSize(400 ,
400)for number in xrange(num_pages):
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()
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()
To copy to clipboard, switch view to plain text mode
How can I get proper size for labels or make them resize automatically?
Bookmarks