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. graphicsView->setScene causes SIGSEGV

graphicsView->setScene causes SIGSEGV

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 271 Views
  • 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.
  • M Offline
    M Offline
    micha_eleric
    wrote on last edited by micha_eleric
    #1
    #include <QApplication>
    #include <QCoreApplication>
    #include <QDebug>
    #include <QtGui>
    #include <QMainWindow>
    #include <QSerialPort>
    #include <QThread>
    #include <cstring>
    #include <fstream>
    #include <functional>
    #include <iostream>
    #include <sstream>
    #include <string>
    #include "Ui_MainWindow.h"
    Ui_MainWindow *m_ui;
    QGraphicsScene * m_GScene;
    m_GScene = new QGraphicsScene();
    m_ui->graphicsView->setScene(m_GScene);
    

    ?graphicsView->setScene causes SIGSEGV?

    not sure where i got graphicsView->setScene

    what is causing SIGSEGV? how to fix?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      micha_eleric
      wrote on last edited by
      #6

      order
      it was the order
      m_ui got assigned after m_ui got called.

      1 Reply Last reply
      0
      • JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by JoeCFD
        #2

        This may not crash. But you know if m_ui and m_ui->graphicsView are defined.

        Ui_MainWindow *m_ui;
        auto m_GScene = new QGraphicsScene;
        if ( nullptr != m_ui && nullptr != m_ui->graphicsView ) {
            m_ui->graphicsView->setScene(m_GScene);
        }
        
        1 Reply Last reply
        0
        • M Offline
          M Offline
          micha_eleric
          wrote on last edited by
          #3
          #include <QApplication>
          
          #include <QGraphicsView>
          #include <QGraphicsScene>
          #include <QPointF>
          #include <QVector>
          
          int main(int argc, char *argv[])
          {
              QApplication a(argc, argv);
              QVector <QPointF> points;
          
              // Fill in points with n number of points
              for(int i = 0; i< 100; i++)
                 points.append(QPointF(i*5, i*5));
          
              // Create a view, put a scene in it and add tiny circles
              // in the scene
              QGraphicsView * view = new QGraphicsView();
              QGraphicsScene * scene = new QGraphicsScene();
              view->setScene(scene);
          
              for(int i = 0; i< points.size(); i++)
                  scene->addEllipse(points[i].x(), points[i].y(), 1, 1);
          
              // Show the view
              view->show();
          
              // or add the view to the layout inside another widget
          
              return a.exec();
          }
          

          this is from stackoverflow, and runs
          what is based my code bit on

          1 Reply Last reply
          0
          • JoeCFDJ Offline
            JoeCFDJ Offline
            JoeCFD
            wrote on last edited by
            #4

            show more of your code if you want to be helped.

            M 1 Reply Last reply
            0
            • JoeCFDJ JoeCFD

              show more of your code if you want to be helped.

              M Offline
              M Offline
              micha_eleric
              wrote on last edited by
              #5

              @JoeCFD said in graphicsView->setScene causes SIGSEGV:

              show more of your code if you want to be helped.

              ok. i included the include files

              1 Reply Last reply
              0
              • M Offline
                M Offline
                micha_eleric
                wrote on last edited by
                #6

                order
                it was the order
                m_ui got assigned after m_ui got called.

                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