Results 1 to 8 of 8

Thread: Still QSqlTableModel and friends trouble

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #8
    Join Date
    Oct 2009
    Posts
    151
    Thanks
    6
    Thanked 13 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Still QSqlTableModel and friends trouble

    Your QSqlTableModel is owned by the MainWindow object and will be automatically destroyed when this is closed (line 56)
    the QTableView and QHeaderView have no parents and will need to be deleted explicitly.
    By deleting the model in line 40 you are unbalancing the call stack which will make the application crash.
    Putting delete operators inside an if statement is rarely a good idea, if they are used at all they should unconditionally delete the object created by new when the object is no longer wanted.

    A better solution would be to give the table and hearde views parents and let QT deal with the garbage collection.
    Last edited by JD2000; 8th January 2010 at 15:26.

Similar Threads

  1. Trouble with "INSERT" by QSqlTableModel
    By AD in forum Qt Programming
    Replies: 12
    Last Post: 10th November 2008, 08:21
  2. Friends Problem in Installing Qt 4.3.2 on Mac Os X
    By nareshqt in forum Installation and Deployment
    Replies: 1
    Last Post: 11th April 2008, 06:35
  3. Hello friends, I have a problem in QT
    By praveen in forum Installation and Deployment
    Replies: 4
    Last Post: 2nd April 2008, 08:36
  4. QSqlTableModel
    By raphaelf in forum Qt Programming
    Replies: 4
    Last Post: 4th March 2006, 12:35

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.