Results 1 to 4 of 4

Thread: How to auto update values on QTableView?

  1. #1
    Join Date
    Jul 2013
    Posts
    22
    Thanks
    10
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default How to auto update values on QTableView?

    For the purpose of visualizing data from a MySQL table, a QTableView is being used in conjunction with a QSqlTableModel. How can I auto update the QTableView as new values are inserted in the database?

    Thanks in advance.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to auto update values on QTableView?

    You need to be notified about changes to the database and rerun the select statement. If your database does not support notifications or your data feeder does not support notifications then you need to implement such system yourself external to the database.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    vrltwe (31st December 2013)

  4. #3
    Join Date
    Jul 2013
    Posts
    22
    Thanks
    10
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to auto update values on QTableView?

    MySQL 5.5.24 (WAMP 2.2) is being used. Could you please provide some details on how this can be done?

    Thanks in advance.
    Last edited by vrltwe; 30th December 2013 at 17:11. Reason: updated contents

  5. #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 auto update values on QTableView?

    AFAICT there is no inbuilt Mysql mechanism to alert an external observer that a table has changed. You can use a trigger to detect updates but to notify an external watcher you would need to use a user-defined function (UDF) to call an external application that broadcasts the notification. Here is an example
    https://help.pubnub.com/entries/2244...abase-Trigger-
    (This will not scale well for high speed inserts)

    You can also use a trigger to update a single row table containing a timestamp that your program can poll. When the timestamp becomes newer than your local last update time then refresh your view. Google has plenty of different variations on this theme.

  6. The following user says thank you to ChrisW67 for this useful post:

    vrltwe (31st December 2013)

Similar Threads

  1. columns in QTableView don't auto stretch
    By aresa in forum Qt Programming
    Replies: 1
    Last Post: 22nd January 2014, 03:59
  2. Replies: 1
    Last Post: 22nd April 2013, 23:42
  3. QTableView and auto scroll
    By ranna in forum Qt Programming
    Replies: 0
    Last Post: 23rd March 2009, 13:02
  4. Replies: 8
    Last Post: 25th February 2008, 17:00
  5. Auto update module
    By munna in forum General Discussion
    Replies: 3
    Last Post: 26th September 2006, 14:52

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.