PDA

View Full Version : QSqlTableModel and QSqlTableView question



waynew
13th December 2009, 03:49
I am going around in circles on this...tried many approaches but none work.
I can make a function to instantiate a table model and table view and the database table displays ok. But the question is, how to reference the model to insert and get the view to show the new data? Tried making the model in the class definition, but that didn't work either. No way to reference the view.
Any ideas are welcome!

ChrisW67
14th December 2009, 01:06
Your view object would typically be member variable of your window class (possibly through a Designer-built class) and accessed there just like accessing any widget in your UI.

You can keep a pointer to the model when your code connects the model to the view if you need to. Alternatively, use QAbstractItemView::model() to retrieve the model pointer from the view as required.