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 (Core Dumped)

Segmentation Fault (Core Dumped)

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 5.5k 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.
  • V Offline
    V Offline
    Vijaeendra
    wrote on last edited by
    #1

    I have got VTK 5.6.1 and Qt 4.6.2 installed on my opensolaris system. I wrote a code which has basic function of showing the VTk viewPort and rendering an image on it. The Class code is as given below.

    @MainWindow::MainWindow(QWidget *parent):QDialog(parent)
    {
    //qvtkWidget= new QVTKWidget;
    button = new QPushButton("Do Something");
    label = new QLabel("Garbage Value");

    connect(button, SIGNAL(clicked()),new helper(label, this), SLOT(onclicked()));
    qvtkWidget->resize(256,256);
    
    vtkPNGReader* reader = vtkPNGReader::New();
    char fname[] ="/export/home/sol/Downloads/vtk/vtk.png";
    reader->SetFileName(fname);
    
    vtkImageViewer* image_view = vtkImageViewer::New();
    image_view->SetInputConnection(reader->GetOutputPort());
    
    qvtkWidget->SetRenderWindow(image_view->GetRenderWindow());
    image_view->SetupInteractor(qvtkWidget->GetRenderWindow()->GetInteractor());
    
    image_view->SetColorLevel(138.5);
    image_view->SetColorWindow(233);*/
    
    //label->setText("My Value");
    
    QGridLayout *layout = new QGridLayout;
    

    // layout->addWidget(qvtkWidget);
    layout->addWidget(button);
    layout->addWidget(label);
    setLayout(layout);
    }

    void MainWindow::MyEventHandler()
    {
    //Label setting
    label->setText("Dude It works");

    //VTK Widget interaction
    vtkPNGReader* reader = vtkPNGReader::New();
    char fname[] ="/export/home/sol/Downloads/vtk/Earth-icon.png";
    reader->SetFileName(fname);
    
    vtkImageViewer* image_view = vtkImageViewer::New();
    image_view->SetInputConnection(reader->GetOutputPort());
    
    qvtkWidget->SetRenderWindow(image_view->GetRenderWindow());
    image_view->SetupInteractor(qvtkWidget->GetRenderWindow()->GetInteractor());
    
    image_view->SetColorLevel(138.5);
    image_view->SetColorWindow(233);
    

    }

    helper::helper(QLabel *label, MainWindow *reciever)
    {
    mylabel= label;
    this->reciever=reciever;
    }

    void helper:: onclicked()
    {
    //reciever->changetext(mylabel);
    reciever->MyEventHandler();

    }

    void MainWindow::changetext(QLabel *label)
    {
    label->setText("changed");
    } @

    But when I run the application file It says segmentation fault(Core Dumped) . But I don see anything wrong with the pointers or anything that I have used.
    Also when I include the (LIBS += -L/usr/local/lib/vtk-5.6 -lQVTK -lvtkRendering -lvtkIO -lvtkFiltering) …. in the .pro file I have this problem. Though I am not using any of its classes(QVTKWidget etc..,) But if I comment that line it works fine.

    Its a run time error and is related to the Shared Libraries.

    I have also set the LD_LIBRARY_PATH!!!

    What Might have gone wrong.

    I am totally stuck, Please Hel

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

      Run into valgrind using the memcheck tool.

      Software Engineer
      KDAB (UK) Ltd., a KDAB Group company

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

        I ll do that., But might there be a chance of the VTK library built wrongly?? What might be the other possibilities why it failing?

        1 Reply Last reply
        0
        • V Offline
          V Offline
          VitorAMJ
          wrote on last edited by
          #4

          @ //qvtkWidget= new QVTKWidget;
          button = new QPushButton("Do Something");
          label = new QLabel("Garbage Value");

          connect(button, SIGNAL(clicked()),new helper(label, this), SLOT(onclicked()));
          qvtkWidget->resize(256,256);@
          

          Why is the QVTKWidget instance creation commented? You are using it as a pointer when resizing it, but its creation is commented in the constructor
          @//qvtkWidget= new QVTKWidget;@

          Maybe uncommenting that line, :) , can solve the problem. Just a guess...

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

            Thanks.., but the problem i m getting stuck is different!! :-) May be I have gone wrong in the building process.

            1 Reply Last reply
            0
            • V Offline
              V Offline
              VitorAMJ
              wrote on last edited by
              #6

              I am sorry I can't help

              bq. I ll do that., But might there be a chance of the VTK library built wrongly?? What might be the other possibilities why it failing?

              Look, I don't want to alarm you, but my colleagues experience setting vtk up is not good...

              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