Results 1 to 2 of 2

Thread: new rows added using MySQL and QSqlTableModel aren't added at the end

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: new rows added using MySQL and QSqlTableModel aren't added at the end

    If you do not specify an ORDER BY clause in your selection SQL then the order that rows are returned from an RDBMS is not defined or guaranteed. Often the retrieval order is governed by the index or indexes used during query execution. For example, a hash-based index will give what appears a random ordering. Other reasons for seemingly random order are that new rows may be inserted into database pages in the space vacated by deleted rows.

    If you have an ID that is monotonically increasing then just ORDER BY that column (by using QSqlTableModel::setSort() in this case).

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

    scot_hansen (29th October 2010)

Similar Threads

  1. Save added Data to a GUI
    By bostero22 in forum Qt Programming
    Replies: 1
    Last Post: 8th June 2010, 15:27
  2. Monitor a new added File
    By designer.software in forum Qt Programming
    Replies: 1
    Last Post: 27th February 2010, 09:50
  3. How can I added a button to QGrahpicsScene
    By learning_qt in forum Qt Programming
    Replies: 1
    Last Post: 21st September 2009, 08:51
  4. Replies: 3
    Last Post: 21st August 2009, 11:39
  5. Data not being added to my QTableView?
    By steg90 in forum Qt Programming
    Replies: 1
    Last Post: 20th November 2007, 14:20

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.