Results 1 to 3 of 3

Thread: my window disappears quickly

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanks
    62
    Thanked 260 Times in 246 Posts

    Default 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:
    Qt Code:
    1. drawGraph *g = new drawGraph; //create a pointer and allocate with new
    2. g->show(); // use -> to access members
    To 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)

  2. The following user says thank you to Zlatomir for this useful post:

    zoz (30th May 2010)

Similar Threads

  1. Focus in QDockWidget disappears
    By Debilski in forum Qt Programming
    Replies: 3
    Last Post: 30th March 2011, 12:40
  2. QGraphicsView scroll bars disappears
    By jano_alex_es in forum Qt Programming
    Replies: 4
    Last Post: 25th November 2009, 14:17
  3. QTableView, QSqlTableModel - data disappears
    By msh in forum Qt Programming
    Replies: 1
    Last Post: 15th November 2008, 11:50
  4. Character from argument disappears
    By Pepe in forum Qt Programming
    Replies: 13
    Last Post: 19th June 2007, 23:48
  5. Displaying Text Quickly
    By taylor34 in forum Qt Programming
    Replies: 6
    Last Post: 2nd March 2006, 14:09

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
  •  
Qt is a trademark of The Qt Company.