Results 1 to 7 of 7

Thread: QGraphicsScene::items() Segmentation Fault

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2012
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QGraphicsScene::items() Segmentation Fault

    I cannot find a way to get the item lists from a QGraphicsScene. When trying the items() method, the program always crashes with a segfault.

    Here is the bit of code where the problem occurs:

    Qt Code:
    1. void MainWindow::updateMapView() {
    2. scene->addRect(QRectF(0, 0, 10, 10), scenePen, sceneBrush);
    3. QList<QGraphicsItem*> items = scene->items();
    4. for (int i = 0; i < items.size(); i++) {
    5. scene->addItem(items[i]);
    6. }
    7. ui.map_view->setScene(scene);
    8. }
    To copy to clipboard, switch view to plain text mode 

    If I remove the middle four lines (and just add the QRectF and set the scene), the code runs fine and the rectangle is displayed. Once I try and get the items, I get the fault.

    Any hints? I'm at a bit of a loss. Thanks.

    Edit: This also occurs for some other functions too, including QGraphicsScene::width() and height(). Not addItem(), or any of the other add functions though.
    Last edited by pmwalk; 22nd February 2012 at 23:34.

Similar Threads

  1. segmentation fault!!
    By Yayati.Ekbote in forum Qt Programming
    Replies: 4
    Last Post: 24th March 2010, 15:10
  2. segmentation fault
    By navid in forum Qt Programming
    Replies: 3
    Last Post: 20th December 2009, 11:40
  3. Segmentation fault
    By impeteperry in forum Qt Programming
    Replies: 5
    Last Post: 29th December 2008, 18:59
  4. Segmentation Fault
    By merry in forum General Programming
    Replies: 4
    Last Post: 12th March 2007, 04:08
  5. QGraphicsScene segmentation fault
    By maxpower in forum Qt Programming
    Replies: 2
    Last Post: 20th November 2006, 18:28

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.