QGraphicsView crash on large size items in PyQt
hi friends.
i have a QGraphicsScene with around 400 labels in it. when i increase initial size of labels program crashes.
Code:
scene.
setBackgroundBrush(QtGui.
QColor('white'))graphics_widget = QtGui.QGraphicsWidget()
layout = QtGui.QGraphicsLinearLayout(QtCore.Qt.Vertical)
page_size
= QtCore.
QSize(995,
1242)for number in xrange(400):
lbl.setFixedSize(page_size)
lbl.setContentsMargins(0, 0, 0, 0)
lbl.setScaledContents(True)
widget = scene.addWidget(lbl)
layout.addItem(widget)
graphics_widget.setLayout(layout)
scene.addItem(graphics_widget)
self.gs_view.setScene(scene)
self.gs_view.show()
but when i decrease initial size of labels to ie QtCore.QSize(695, 942) it does not crash. sometimes when i scale QGraphicsView and my application memory usage is around 250mb i get and out of memory error and application exits automatically.
thank you.
Re: QGraphicsView crash on large size items in PyQt
when i reduce number of pages (ie 30) program works fine with large size labels otherwise i should reduce size of labels or reduce number of pages.
for this project i should use PyQt 4.8.5 (Qt 4.7.4)
Re: QGraphicsView crash on large size items in PyQt
Adding widgets to a graphicsscene should only be done if really needed, e.g. complex widgets or when needing platform styling of controls.
QLabel fits neither
Cheers,
_
Re: QGraphicsView crash on large size items in PyQt
i want to write a docuement viewer and because of that i should initiate blank pages and when user scroll to a specific page render page's pixmap and show it to user.
even when i initiate pages with a small size and scale QGraphicsView some times i get out of memory error
Re: QGraphicsView crash on large size items in PyQt
You might want to use a QListView then.
No point in creating visual delegates for things that cannot be seen.
Cheers,
_