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:
Qt Code:
drawGraph *g = new drawGraph; //create a pointer and allocate with new g->show(); // use -> to access membersTo copy to clipboard, switch view to plain text mode
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)
Bookmarks