Results 1 to 4 of 4

Thread: Qt models and multi-threaded inserts

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,329
    Thanks
    317
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Qt models and multi-threaded inserts

    These two statements seem inconsistent to me:

    The model models a global datastore in my program, but this store is internally threadsafe, and it's assumed that multiple threads will modify the data in it
    the model abstracts my global store, and no other place accesses my global store.
    If your global store has only one client (second statement), why do you say multiple threads will modify it (first statement)? Do you mean to say that in your program, your model is the only accessor of the data store, but there could be other programs that are also accessing and possibly modifying it?

    You might have to implement more than just the beginResetModel / endResetModel methods - like those for row insertion and removal - unless you want to completely reload the table view every time the database changes.

    Presumably the QSqlTableModel and QSqlTableView classes have been implemented to handle the scenario you are describing. It might be worthwhile to study that source code for ideas. If your data store is based on an SQL DB, then you might be able to use those classes instead of rolling your own.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

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

    tuli (11th November 2024)

Similar Threads

  1. Multi-threaded rendering advice
    By jcox23 in forum Qt Programming
    Replies: 0
    Last Post: 5th November 2012, 11:25
  2. Debugging a multi threaded windows app
    By Cruz in forum Qt Programming
    Replies: 5
    Last Post: 10th April 2012, 12:46
  3. signal not emitting from run() in multi-threaded app
    By naturalpsychic in forum Qt Programming
    Replies: 6
    Last Post: 8th April 2011, 05:28
  4. Multi-threaded GUI possible?
    By nurtsi in forum Qt Programming
    Replies: 12
    Last Post: 26th November 2010, 21:52
  5. Qstring toStdString() and Multi-threaded DLL (/MD)
    By Daxos in forum Qt Programming
    Replies: 14
    Last Post: 15th May 2010, 11:57

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.