Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Segmentation fault in QGraphicsView::setScene()
Forum Updated to NodeBB v4.3 + New Features

Segmentation fault in QGraphicsView::setScene()

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 3.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    soroush
    wrote on last edited by
    #1

    Hello forum

    I have a normal widget application which should show a finite automata in a graphic view widget. I add a QGgraphicsView to the main window, which has an instance of QGraphicsScene:
    @
    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    scene(new QGraphicsScene(this))
    {
    setupUi(this);
    scene->addText("Hello");
    ui->graphicsView->setScene(scene); // bumb!
    }
    @
    Program crashes by a segmentation fault when it tries to set scene for graphicsView.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dbzhang800
      wrote on last edited by
      #2

      @
      ui->...
      @
      wild pointer?

      1 Reply Last reply
      0
      • V Offline
        V Offline
        veeraps
        wrote on last edited by
        #3

        scene is just constructed in initialization list using new operator. So I trust the new operator won't screw it up.
        @ui->graphicsView->setScene(scene); // bumb!@

        Looking at the above line - could be because of either 'ui' or 'graphicsView' - may be not a valid pointer?

        1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #4

          Since you didn't include the class definition, mine is just a guess but try deleting ui-> or replacing it with this->
          leave just
          @graphicsView->setScene(scene);@ and see if it work (it should ;) )

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply
          0
          • V Offline
            V Offline
            veeraps
            wrote on last edited by
            #5

            Or may be try clean and build or rebuild.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved