Results 1 to 7 of 7

Thread: Qt app runs in creator but crashes from command line

  1. #1
    Join Date
    Apr 2017
    Posts
    53
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

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

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,719
    Thanks
    259
    Thanked 760 Times in 750 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default 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.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Jun 2017
    Posts
    8
    Qt products
    Qt3 Qt5
    Platforms
    Windows

    Default 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 :
    Qt Code:
    1. #include <QObject>
    2. #include <QApplication>
    3. #include <QWidget>
    4. #include <QBoxLayout>
    5. #include <QDoubleSpinBox>
    6. #include <QLabel>
    7. #include <QInputDialog>
    8. #include <QString>
    9. #include <QFormLayout>
    10. #include <QHBoxLayout>
    11. #include <QVector>
    12. #include <QVBoxLayout>
    13.  
    14.  
    15. int main(int argc, char *argv[])
    16. {
    17. QApplication app(argc, argv);
    18. QWidget fenetre;
    19. QVector<QFormLayout*> layout(5);
    20. QVector<QDoubleSpinBox*> note(5);
    21. QVector<QString> liste(5);
    22. QVBoxLayout *vlayout=new QVBoxLayout;
    23. QString eleve;
    24. bool ok(false);
    25. int i(0);
    26. for(i=0;i<5;i++){eleve=QInputDialog::getText(&fenetre,
    27. "Question","Saisissez le nom de l'eleve",QLineEdit::Normal,QString(),&ok);
    28. if(ok&&!eleve.isEmpty()){liste[i]=eleve;}
    29. else {i--;}}
    30. 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));}
    31. fenetre.setLayout(vlayout);
    32. fenetre.show();
    33. return app.exec();
    34. }
    To copy to clipboard, switch view to plain text mode 
    This is the message displayed after i've put all names required by the QInputDialogue:
    Qt Code:
    1. Démarrage de C:\Users\yayah\Documents\build-TEST-Desktop_Qt_5_6_2_MinGW_32bit-Debug\debug\TEST.exe...
    2. Le programme s'est terminé subitement.
    3. C:\Users\yayah\Documents\build-TEST-Desktop_Qt_5_6_2_MinGW_32bit-Debug\debug\TEST.exe crashed.
    To copy to clipboard, switch view to plain text mode 

    Please help me!!!!!
    Last edited by joovoo; 25th June 2017 at 16:45.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,719
    Thanks
    259
    Thanked 760 Times in 750 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default 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.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  5. #5
    Join Date
    Jun 2017
    Posts
    8
    Qt products
    Qt3 Qt5
    Platforms
    Windows

    Default 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?

  6. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,719
    Thanks
    259
    Thanked 760 Times in 750 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default 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++.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  7. #7
    Join Date
    Jun 2017
    Posts
    8
    Qt products
    Qt3 Qt5
    Platforms
    Windows

    Default Re: Qt app runs in creator but crashes from command line

    Ok !Excuse me for doing that...! So i do stop that now.

Similar Threads

  1. Execute window command line-by-line using QProcess
    By nhocjerry in forum Qt Programming
    Replies: 5
    Last Post: 30th July 2013, 13:21
  2. Program runs from Creator, but not as a standalone?
    By N3wb in forum Qt Programming
    Replies: 12
    Last Post: 9th October 2012, 00:11
  3. Replies: 0
    Last Post: 8th August 2012, 18:49
  4. Program runs on Windows 7, crashes on Windows XP
    By JovianGhost in forum General Programming
    Replies: 8
    Last Post: 7th June 2010, 01:55
  5. Replies: 5
    Last Post: 5th October 2008, 06:12

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.