Results 1 to 2 of 2

Thread: QSqlTableModel and QSqlTableView question

  1. #1
    Join Date
    May 2009
    Location
    USA
    Posts
    300
    Thanks
    82
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Unhappy QSqlTableModel and QSqlTableView question

    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!

  2. #2
    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: QSqlTableModel and QSqlTableView question

    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.

Similar Threads

  1. QSqlTableModel, QTableView and complex queries
    By Walter in forum Qt Programming
    Replies: 8
    Last Post: 15th November 2009, 02: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.