The .exe file has stopped working error



  • Hi all,

    As the book would say, I designed a form like this: alt text

    A .h file like this:

    #ifndef SORTDIALOG_H
    #define SORTDIALOG_H
    
    #include <QDialog>
    #include "ui_sortdialog.h"
    
    class SortDialog : public QDialog, public Ui::SortDialog
    {
        Q_OBJECT
    public:
        SortDialog(QWidget* parent = 0);
        void setColumnRange(QChar first, QChar last);
    };
    
    #endif // SORTDIALOG_H
    

    a .cpp file like this:

    #include <QtWidgets>
    #include "sortdialog.h"
    
    SortDialog::SortDialog(QWidget *parent)
        :QDialog(parent)
    {
        setupUi(this);
    
        secondaryGroupBox -> hide();
        tertiaryGroupBox -> hide();
        layout() -> setSizeConstraint(QLayout::SetFixedSize);
    
        setColumnRange('A', 'Z');
    }
    
    void SortDialog::setColumnRange(QChar first, QChar last)
    {
        primaryColumnCombo -> clear();
        secondaryColumnCombo -> clear();
        tertiaryColumnCombo -> clear();
    
        secondaryColumnCombo -> addItem(tr("None"));
        tertiaryColumnCombo -> addItem(tr("None"));
        primaryColumnCombo -> setMinimumSize(
                    secondaryColumnCombo -> sizeHint());
    
        QChar ch = first;
        while(ch <= last) {
            primaryColumnCombo -> addItem(QString(ch));
            secondaryColumnCombo -> addItem(QString(ch));
            tertiaryColumnCombo -> addItem(QString(ch));
            ch = ch.unicode() + 1;
        }
    }
    

    and the main.cpp this way:

    #include <QApplication>
    #include "sortdialog.h"
    
    int main(int argc, char* argv[])
    {
        QApplication app(argc, argv);
        SortDialog* dialog = new SortDialog;
        dialog -> setColumnRange('C', 'F');
        dialog -> show();
        return app.exec();
    }
    

    After running qmake and adding QT += widgets to the .pro file, I ran the program, but, I got this error! :( alt text

    What is the problem please?
    I did these steps: From Build:
    Clean all
    Run qmake
    Build all

    But no success!



  • Hello,

    have you tried debugging the Application to see where it crashes?



  • @onek24
    Thanks for the reply.
    I debugged the program by F5 and got this: alt text



  • Add a spacer under the more button then right click on the background and select layout->lay out horizontaly

    The sign that shows the problem is the red sign on the sortdialog windows in the top right of your first screenshot. that means that layout() is null


Log in to reply
 

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