Qt app runs in creator but crashes from command line
I built an app with Qtcreator with a gui. it compiles without warnings or errors and runs perfectly from Creator. When I compile from the command line, one of the button functions causes the app to crash. Does the app need something special from Qtcreator in order to run from the command line??
Thanks in Advance.
Re: Qt app runs in creator but crashes from command line
A crash in release mode usually means you are accessing a NULL or uninitialized pointer, that you haven't properly initialized a variable and use it before it is initialized, that you are trying to load a resource or something and then try to use it before checking if loading was successful, or any number of other programming errors. A crash is almost always your problem.
Running in a debugger under any IDE is different from running on the command line. The debugger generally initializes variables to known values so you can recognize them as such when debugging. Qt Creator also sets up an environment where resources and other things can be found when needed. Neither of these is true of the command line.
Re: Qt app runs in creator but crashes from command line
Good Morning d_stranz! First excuse me to bother u whith my poor nknowledge in english.I get a similar problem: My Qt program crashe whithout the warning or error of the compiler after running perfectly in Qt creator.My program consist of ask names of five students using a QInputDialgue and try to put those names in a vertical alignment in a window, using a QFormLayout of QLabel and QDoubleSpinBox.This is the code :
Code:
#include <QObject>
#include <QApplication>
#include <QWidget>
#include <QBoxLayout>
#include <QDoubleSpinBox>
#include <QLabel>
#include <QInputDialog>
#include <QString>
#include <QFormLayout>
#include <QHBoxLayout>
#include <QVector>
#include <QVBoxLayout>
int main(int argc, char *argv[])
{
QVector<QFormLayout*> layout(5);
QVector<QDoubleSpinBox*> note(5);
QVector<QString> liste(5);
bool ok(false);
int i(0);
if(ok&&!eleve.isEmpty()){liste[i]=eleve;}
else {i--;}}
for(i=0;i<5;i++){(layout.at(i))->addRow(liste.at(i),note.at(i));}for(i=0;i<5;i++){vlayout->addLayout(layout.at(i));}
fenetre.setLayout(vlayout);
fenetre.show();
return app.exec();
}
This is the message displayed after i've put all names required by the QInputDialogue:
Code:
Démarrage de C:\Users\yayah\Documents\build-TEST-Desktop_Qt_5_6_2_MinGW_32bit-Debug\debug\TEST.exe...
Le programme s'est terminé subitement.
C:\Users\yayah\Documents\build-TEST-Desktop_Qt_5_6_2_MinGW_32bit-Debug\debug\TEST.exe crashed.
Please help me!!!!!
Re: Qt app runs in creator but crashes from command line
Your QVector< QFormLayout > and QVector< QSpinBox > are declared but they are never initialized. When you try to use them in line 30, your program crashes.
But there is so much else wrong with your program that even if you did initialize the vectors correctly, your program probably still would not run.
Re: Qt app runs in creator but crashes from command line
Ok! THanks for the answer. So what are those wrong things and how can i initialiZe thoses vectors please?
Re: Qt app runs in creator but crashes from command line
Look, you've hijacked a thread that wasn't yours to start with, so I am not going to reply any more to it.
If you don't know the difference between declaring and initializing, you need to go back to your C++ book and look it up. We're not here to teach basic C++.
Re: Qt app runs in creator but crashes from command line
Ok !Excuse me for doing that...! So i do stop that now.