Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6012841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:27:45+00:00 2026-05-23T02:27:45+00:00

I have been working on a Qt Creator application, and just recently ran into

  • 0

I have been working on a Qt Creator application, and just recently ran into a run-time error that I have no idea how to find and fix. The program just unexpectedly finishes once it starts up, and when I run the debug, it gives me the error:

The inferior stopped because it
received a signal from the operating
system.

Signal name: SIGSEGV

Signal meaning: Segmentation fault

Now I understand that this error is caused by attempted access to an invalid memory location, but I have absolutely no clue what I did to trigger it. The debugger seems to be pointing me to a specific line of code:

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QString>
#include "ui_mainwindow.h"
#include "foamdata.h"
#include "domaingeneration.h"


namespace Ui {
    class MainWindow;
}


class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
    int getXDim() const { return ui->xDim->value(); } // THIS is where it points to!!
    int getYDim() const { return ui->yDim->value(); }


private slots:
    void on_findDir_clicked();

    void on_create_clicked();

    void on_generateDomain_clicked();

private:
    Ui::MainWindow *ui;
    DomainGeneration dg;    //declaring second window as a member of main window
};

#endif // MAINWINDOW_H

That function is used in this:

#include "domaingeneration.h"
#include "ui_domaingeneration.h"
#include <QCheckBox>
#include "mainwindow.h"

DomainGeneration::DomainGeneration(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DomainGeneration)
{
    ui->setupUi(this);

    // Generating checkboxes for domain generation
    MainWindow* main;
    int x_dim = main->getXDim();
    int y_dim = main->getYDim();
    QVector<QCheckBox*> checkBoxVector;
    for(int i = 0; i < x_dim; ++i){
        for(int j = 0; j < y_dim; ++j){
            checkBoxVector.append(new QCheckBox(this));
            checkBoxVector.last()->setGeometry(i * 20, j * 20, 20, 20);
        }
    }
}


DomainGeneration::~DomainGeneration()
{
    delete ui;
}

Here is the mainwindow source code:

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "functions.h"
#include "main.cpp"
#include <QtGui/QApplication>
#include <QFileDialog>
#include <fstream>
#include "foamdata.h"
#include "domaingeneration.h"


MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}




// This is the function that handles the directory search when the 'browse' button is pressed
void MainWindow::on_findDir_clicked()
{
    QString path;   //declaring the path to the base directory

    path = QFileDialog::getExistingDirectory(   //gathering the directory from QFileDialog class
        this, tr("Choose the project directory"),
        "/home",
        QFileDialog::ShowDirsOnly
        | QFileDialog::DontResolveSymlinks );

    ui->baseDir->setText( path );   //setting the retrieved path into the line edit box
}



// This function makes the project by creating a new directory with name 'project_name'
// in the base directory, and collects the OpenFOAM version number and simulation type
void MainWindow::on_create_clicked()
{

    QString project_name, foam_version, full_dir, slash, base_dir;
    base_dir = ui->baseDir->text();
    project_name = ui->projectName->text();     //getting the text from the 'projectName' field
    foam_version = ui->version->currentText();  //getting the selection from the 'version' drop-down box

    project_info.save_version(foam_version);        //saving data in a global project variable
    project_info.save_projName(project_name);
    project_info.save_simType(ui->simType->currentText());

    //first checking if the fields have input in them:
    QString blank = "";
    QString no_text0 = "Please enter project name";
    if( project_name==no_text0 || (project_name==blank) ) {
        ui->projectName->setText( no_text0 );
        return;
    }


    QString no_text1 = "Please enter a valid directory";
    if( base_dir==no_text1 || base_dir==blank || !QDir( base_dir ).exists() ) {
        ui->baseDir->setText( no_text1 );
        return;
    }


    slash = "/";        // needed to separate folders in the directory (can't use a literal)
    full_dir = base_dir.append(slash.append(project_name));
    project_info.save_directory(full_dir);

    if( !QDir(full_dir).exists() )  //check if directory already exists
        QDir().mkdir(full_dir);     //creating directory

    QString blockmesh_filename, suffix;
    suffix = "_blockMeshDict";
    slash = "/";    //must re-define
    blockmesh_filename = full_dir.append( slash.append( project_name.append(suffix) ) );
    std::ofstream create_file( blockmesh_filename.toStdString().c_str() );  //creating empty blockmesh file

}


void MainWindow::on_generateDomain_clicked()    //opening the new window for domain generation
{
    dg.show();
}

Can anybody help me find what the heck is going on?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T02:27:45+00:00Added an answer on May 23, 2026 at 2:27 am

    The obvious is that you’re not initializing MainWindow * main;:

    MainWindow* main; // right here
    int x_dim = main->getXDim();
    int y_dim = main->getYDim();
    

    There might, however, be other uninitialized values, the piece of code presented doesn’t really say much.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on getting my OSGi application to run outside eclipse. It
I have been working with a string[] array in C# that gets returned from
We have been working with CVS for years, and frequently find it useful to
I have been working on some legacy C++ code that uses variable length structures
I have been working with relational databases for sometime, but it only recently occurred
I have been working with Struts for some time, but for a project I
I have been working on a wrapper for a COM object that can only
I have been working on a Core Data iOS app that works perfectly through
I have been working on a project for some time now, and I decided
I've been working on a project that requires draft/live versions of content and have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.