PDA

View Full Version : .exe exited with code -1073741819 (Using QFrame or Qwidget)



Nick Scott
5th January 2012, 18:49
Hi there, I've been looking here about this error, but couldn't find anything about my particular problem

Whenever I try to use a QFrame or a QWidget (like doing frame->SetVisible(true)) the simulator stops working with this error: "archive.exe exited with code -1073741819""

Could anybody help me?

Thanks in advance.

pkj
5th January 2012, 19:08
Have you done frame = new QFrame() anywhere in your code. Most probably the pointer is a dangling pointer. It has been deleted/not new'ed and you are trying to access it...

Nick Scott
5th January 2012, 20:09
Thanks. It was that.

I'm kind of new on this of C++ and Qt. Would you tell me why I have to declare a Qt Frame or Widget and not a pushButton for example?

Thanks again.

ChrisW67
5th January 2012, 20:57
Nothing to do with Qt. This is basic C/C++ knowledge. You must declare any variable before you can use it. You must initialise pointer variables before using them in anger.

Pointer variables, like your "frame" variable, must point at an instance of the object or attempting to use the object will be a Bad ThingTM. This is equally true of a pointer to a QPushButton, QFrame, CoolAndGroovyNonQtClass, or any other. You allocate an object on the heap using operator new, which returns a pointer to the object.

Nick Scott
5th January 2012, 22:09
Thanks. About that of declaring everything...I haven't declared those buttons or mostly anything else but the frame and it still works. Is that a "Bad Thing" that C++ still allows?

And where should I declare those things in C++? I declared the QFrame on my MainWindow, is that orthodox? The other declarations where should they be?

Thanks again.

ChrisW67
5th January 2012, 22:15
Show the code you are referring to. We cannot comment otherwise.

Is your UI built with Designer? If so, the UI file is compiled into equivalent C++ that includes relevant declarations and initialisations.