Results 1 to 5 of 5

Thread: How to update

  1. #1
    Join Date
    Mar 2009
    Posts
    104
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default How to update

    I want an application using SQLite.I use QSQlqueryModel and QTableView to display the data.
    I want when data (the model) changed to update the content displayed in the QTableView.
    When i click on dialog i add new data to the model and when i click on the button ADD i want to close the dialog and on the widget behind to repaint/update the displayed data.

    screenshot.jpg

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: How to update

    And the question is? All you have wrote is perfectly possible with a model and view approach.

  3. #3
    Join Date
    Mar 2009
    Posts
    104
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: How to update

    The question is how to update TableView?I don't use MVC pattern!There should be some method for doing this.

  4. #4
    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: How to update

    QSqlQueryModel is read only: you cannot update the data through the model and the model has no way to know if the data underneath it has been changed externally. If you want to update the data through the model (using the table directly or a dialog that uses the model) then you want a QTableModel or similar. If you only want to refresh the read-only table because you know the underlying data has changed then call setQuery() again.

  5. #5
    Join Date
    Mar 2009
    Posts
    104
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: How to update

    Thank you! I just made a new slot with the query and i trigger it whenever i need an update.

Similar Threads

  1. QFileSystemModel - Incremental update/pre-emptive update
    By johnnyturbo3 in forum Qt Programming
    Replies: 0
    Last Post: 2nd September 2011, 13:56
  2. Update GUI
    By migel in forum Newbie
    Replies: 6
    Last Post: 6th July 2011, 01:29
  3. Replies: 2
    Last Post: 29th September 2010, 17:44
  4. how to use update()?
    By zgulser in forum Qt Programming
    Replies: 0
    Last Post: 6th February 2009, 09:45
  5. update()
    By JeanC in forum Qt Programming
    Replies: 4
    Last Post: 11th February 2008, 16:12

Tags for this Thread

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.