QSqlQueryModel and TableView for dynamic data
-
@JonB
Database insertions/write are done in the working thread.
Database queries/reads are done in the UI thread. -
wrote on 6 Jun 2018, 09:42 last edited by
@JonB
Seems to work, but I will not do it this way...teh database here is just a fake database in order to be able to work in the model while the real db is yet not implemented.Thanks.
Still wondering which model approach will feet better in what I ultimately have to implement. A lists of data that can have thousand of rows and can be updated by another thread (not user interaction). Any suggestions.
-
@JonB
Seems to work, but I will not do it this way...teh database here is just a fake database in order to be able to work in the model while the real db is yet not implemented.Thanks.
Still wondering which model approach will feet better in what I ultimately have to implement. A lists of data that can have thousand of rows and can be updated by another thread (not user interaction). Any suggestions.
wrote on 6 Jun 2018, 09:47 last edited by JonB 6 Jun 2018, 09:51@XDePedro
For the "updated by another thread (not user interaction)", my understanding is that you must not do that directly. If you need to, use signals & slots. You may get away without now, but supposedly not in the long run, under whatever circumstances.Read up on this, e.g. https://stackoverflow.com/questions/20793689/correctly-using-qsqldatabase-in-multi-threaded-programs, and many others.
For the "model approach", I still think you need to answer my earlier question: do you fetch a brand new set of rows and those are the only ones to be shown in the table view, or do you "incrementally" fetch some additional new rows, and want those to be appended to what you already have in the model & the view?
-
wrote on 6 Jun 2018, 12:24 last edited by
Any help about which model should I use? Any help on how implement it?
21/24