my window disappears quickly
Hi everyone..
I have problem in my project..
look at this first:
in dialog3.cpp
Code:
void Dialog3::openD4()
{
drawGraph g;
g.show();
}
I have drawGraph.h , drawGraph.cpp ,and drawGraph.ui files
( I draw circles and add bottons inside it)
I call them window by define object and call show functon to display it after dialog3..
but it disappears quickly
so, I cann't see it!
when I call it in main.cpp,it doesn't disappear!!
anyone have idea about that?
Re: my window disappears quickly
That happens because you allocate memory (for your g) on that function stack.
You should allocate memory on the heap, so the object remains after the function terminates, like this:
Code:
drawGraph *g = new drawGraph; //create a pointer and allocate with new
g->show(); // use -> to access members
And make sure that your g pointer gets a parent, or else you should call delete g; in the class destructor (so that you wont get a memory leak)
Re: my window disappears quickly
Quote:
Originally Posted by
Zlatomir
That happens because you allocate memory (for your g) on that function stack.
You should allocate memory on the heap, so the object remains after the function terminates, like this:
Code:
drawGraph *g = new drawGraph; //create a pointer and allocate with new
g->show(); // use -> to access members
And make sure that your g pointer gets a parent, or else you should call delete g; in the class destructor (so that you wont get a memory leak)
Thanks a lot
Thanks a lot Zlatomir
I see my window now clearly :)
I am grateful to you for helping..
thanks again..
\