[Solved] Program has unexpectedly crashed.



  • Hi, so I have a GUI and I'm currently creating an additional GUI, the additional GUI is just a directory folder that needs to select a folder. I recently started working on my directory finder but now when I try to populate my GUI, it crashes, no errors at al.

    Here's my codes:

    directoryexplorer.cpp
    @#include "directoryexplorer.h"
    #include "ui_directoryexplorer.h"
    #include "mainwindow.h"

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

    mmodel = new QDirModel(this);
    mmodel->setReadOnly(false);
    ui->treeView->setModel(mmodel);
    

    }

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

    void directoryExplorer::on_selectButton_clicked()
    {
    //SELECT DIR
    }
    @

    mainwindow.cpp
    @#include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include "QCheckBox"
    #include "QString"
    #include "QLineEdit"
    #include "directoryexplorer.h"

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

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

    void MainWindow::toggleCheckBox(QCheckBox *checkBox,QLineEdit *lineEdit){
    QString text = lineEdit->text();
    if(text == ""){
    checkBox->setChecked(false);
    }else{
    checkBox->setChecked(true);
    }
    }

    void MainWindow::on_lineEditCreateServerFile_textEdited()
    {
    MainWindow::toggleCheckBox(ui->checkBoxCreateServerFile,ui->lineEditCreateServerFile);
    }
    void MainWindow::on_lineEditCreateClientFile_textEdited()
    {
    MainWindow::toggleCheckBox(ui->checkBoxCreateClientFile,ui->lineEditCreateClientFile);
    }

    void MainWindow::on_lineEditAuthor_textEdited()
    {
    MainWindow::toggleCheckBox(ui->checkBoxAuthor,ui->lineEditAuthor);
    }

    void MainWindow::on_lineEditVersion_textEdited()
    {
    MainWindow::toggleCheckBox(ui->checkBoxVersion,ui->lineEditVersion);
    }

    void MainWindow::on_lineEditName_textEdited()
    {
    MainWindow::toggleCheckBox(ui->checkBoxName,ui->lineEditName);
    }

    void MainWindow::on_lineEditDescription_textEdited()
    {
    MainWindow::toggleCheckBox(ui->checkBoxDescription,ui->lineEditDescription);
    }

    void MainWindow::on_lineEditType_textEdited()
    {
    MainWindow::toggleCheckBox(ui->checkBoxType,ui->lineEditType);
    }

    void MainWindow::on_pushButton_clicked()
    {
    //render dir expl
    de.show();

    }

    void MainWindow::on_pushButtonOutput_clicked()
    {
    //GENERATE FILES
    }

    @

    Aaand both of my headers incase they're needed:

    @#ifndef DIRECTORYEXPLORER_H
    #define DIRECTORYEXPLORER_H

    #include <QWidget>
    #include "QDirModel"

    namespace Ui {
    class directoryExplorer;
    }

    class directoryExplorer : public QWidget
    {
    Q_OBJECT

    public:
    explicit directoryExplorer(QWidget *parent = 0);
    ~directoryExplorer();

    private slots:
    void on_selectButton_clicked();

    private:
    Ui::directoryExplorer *ui;
    QDirModel *mmodel;
    };

    #endif // DIRECTORYEXPLORER_H
    @

    @#ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include <QMainWindow>
    #include "QCheckBox"
    #include "QLineEdit"
    #include "directoryexplorer.h"

    namespace Ui {
    class MainWindow;
    }

    class MainWindow : public QMainWindow
    {
    Q_OBJECT

    public:
    void toggleCheckBox(QCheckBox *checkBox,QLineEdit *lineEdit);
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

    private slots:
    void on_lineEditCreateServerFile_textEdited();

    void on_lineEditCreateClientFile_textEdited();
    
    void on_lineEditAuthor_textEdited();
    
    void on_lineEditVersion_textEdited();
    
    void on_lineEditName_textEdited();
    
    void on_lineEditDescription_textEdited();
    
    void on_lineEditType_textEdited();
    
    void on_pushButton_clicked();
    
    void on_pushButtonOutput_clicked();
    

    private:
    Ui::MainWindow *ui;
    directoryExplorer de;
    };

    #endif // MAINWINDOW_H
    @

    I know my code looks like a clusterbomb has dropped on it but I'm still learning, thanks in advance.


  • Moderators

    You posted directoryexplorer.cpp twice. I don't see anything wrong in it. Maybe it's in mainwindow.cpp.

    Btw. QDirModel is deprecated. You should be using "QFileSystemModel":http://qt-project.org/doc/qt-5/qfilesystemmodel.html



  • [quote author="Chris Kawa" date="1397303679"]You posted directoryexplorer.cpp twice. I don't see anything wrong in it. Maybe it's in mainwindow.cpp.

    Btw. QDirModel is deprecated. You should be using "QFileSystemModel":http://qt-project.org/doc/qt-5/qfilesystemmodel.html[/quote]

    fixed.
    edit: I mean the mistake in the post. In meanwhile I've replaced it with QFSM, still crashing.


  • Moderators

    Hi,

    What info do you get when you run your program from a debugger?



  • [quote author="JKSH" date="1397308918"]Hi,

    What info do you get when you run your program from a debugger?[/quote]

    It started working again after numerous times of cleaning.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.