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. [Solved] Program has unexpectedly crashed.
Forum Updated to NodeBB v4.3 + New Features

[Solved] Program has unexpectedly crashed.

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 1.5k 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.
  • G Offline
    G Offline
    glowdemon1
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • G Offline
        G Offline
        glowdemon1
        wrote on last edited by
        #3

        [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.

        1 Reply Last reply
        0
        • JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #4

          Hi,

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

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          1 Reply Last reply
          0
          • G Offline
            G Offline
            glowdemon1
            wrote on last edited by
            #5

            [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.

            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