c++ - getting stuck with "segmentation fault" in Qt while using Qt creator to create a very simple project -


here source code, super one:

#include<qapplication> #include<qlabel> int main(int argc,char* argv[]) {    qapplication app(argc,argv);    qlabel *label=new qlabel("hello world");    label->show();    return app.exec(); } 

when build it, good. when try run it, stop, telling me "*.exe have stop. close or debug it.".

so try debug it. after while, throw out message:

the inferior stopped because received signal operating system   sinal name: sigsegv  signal meaning: segmentation default 

i went check lot on google , stackoverflow , wikipedia. many people caused wrong use of pointer. can't find out problem is. please help.

by way, i'm using win7 , have try on qt 4.8.5 , qt 5.4.0. compilers , debuggers good(at least qt creator show no error).

should reinstall qt or else?

here wrong code(in qatomic_i386.h) debugger point out me:

inline bool qbasicatomicint::deref() {         unsigned char ret;     asm volatile("lock\n"                  "decl %0\n"                  "setne %1"                  : "=m" (_q_value), "=qm" (ret)                  : "m" (_q_value)                   : "memory");   //this wrong code debugger point out me   return ret != 0; } 

another line in qstring.h:

inline qstring::~qstring() { if (!d->ref.deref()) free(d); } 

that's wrong information. thanks.

*****************code change***but same******

#include<qapplication> #include<qlabel> #include<qdialog>  int main(int argc,char* argv[]) {     qapplication app(argc,argv);     qdialog* dialog=new qdialog;     qlabel* label=new qlabel(dialog);     label->settext("hello world");     dialog->show();     //label->show();    it's same or without      return app.exec(); } 

***********more changed same*********

#include<qapplication> #include<qlabel> #include<qdialog>  int main(int argc,char* argv[]) {     qapplication app(argc,argv);     qdialog dialog;     qlabel label(&dialog);     label.settext("hello world");     dialog.show();     //label->show();      return app.exec(); } 

please check .pro file not trying console application,you must use qwidet appplication.:

#------------------------------------------------- # # project created qtcreator 2015-05-04t11:12:27 # #-------------------------------------------------  qt       += core gui greaterthan(qt_major_version, 4): qt += widgets   target = testapp   template = app   sources += main.cpp 

app working me code,,,,it runs procces_stub.exe cmd , show label on window...


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -