Results 1 to 5 of 5

Thread: QGraphicsView crash on large size items in PyQt

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2015
    Posts
    17
    Thanks
    3
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default 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.

    Qt Code:
    1. scene = QtGui.QGraphicsScene()
    2. scene.setBackgroundBrush(QtGui.QColor('white'))
    3. graphics_widget = QtGui.QGraphicsWidget()
    4. layout = QtGui.QGraphicsLinearLayout(QtCore.Qt.Vertical)
    5. page_size = QtCore.QSize(995, 1242)
    6. for number in xrange(400):
    7. lbl = QtGui.QLabel()
    8. lbl.setFixedSize(page_size)
    9. lbl.setContentsMargins(0, 0, 0, 0)
    10. lbl.setScaledContents(True)
    11.  
    12. widget = scene.addWidget(lbl)
    13. layout.addItem(widget)
    14.  
    15. graphics_widget.setLayout(layout)
    16. scene.addItem(graphics_widget)
    17. self.gs_view.setScene(scene)
    18. self.gs_view.show()
    To copy to clipboard, switch view to plain text mode 

    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.

  2. #2
    Join Date
    Oct 2015
    Posts
    17
    Thanks
    3
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default 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)
    Last edited by Santa.fat; 30th October 2015 at 09:46.

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default 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,
    _

  4. The following user says thank you to anda_skoa for this useful post:

    Santa.fat (30th October 2015)

  5. #4
    Join Date
    Oct 2015
    Posts
    17
    Thanks
    3
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default 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
    Last edited by Santa.fat; 30th October 2015 at 12:15.

  6. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default 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,
    _

Similar Threads

  1. Multicast large data size
    By bon_scott in forum General Programming
    Replies: 9
    Last Post: 29th May 2015, 05:34
  2. Replies: 5
    Last Post: 7th September 2011, 13:59
  3. Replies: 0
    Last Post: 26th October 2010, 18:59
  4. Qt displays large size jpg
    By omegas in forum Qt Programming
    Replies: 14
    Last Post: 22nd April 2010, 06:07
  5. Replies: 4
    Last Post: 18th August 2009, 20:53

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.