Results 1 to 3 of 3

Thread: Automatic updating of SQLmodel

  1. #1
    Join Date
    Jun 2010
    Posts
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Automatic updating of SQLmodel

    Hi

    given the following problem:

    I have a VIEW in a PostgreSQL Database which I want to display in a TableView in a Qt program. So I use a QSqlQueryModel and a QTableView, that far no problem...

    But the content of the database can be changed externally and when this happens, the VIEW changes accordingly. But my model is not updated because it is not notified of the change of the database view and therefore the QTableView also doesn't change.

    How can I achieve an automatic update of the model on changes in the database?

    Thanks
    Markus

  2. #2
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Automatic updating of SQLmodel

    Can the application that initiates the change to the database notify your program?

    I'm not that familiar with PostgreSQL, but doesn't it support notification events? Check the 'notify' command.

    good luck

  3. #3
    Join Date
    Jun 2010
    Posts
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Automatic updating of SQLmodel

    > Can the application that initiates the change to the database notify your program?

    that will unfortunately not work....

    > I'm not that familiar with PostgreSQL, but doesn't it support notification events? Check the 'notify'
    > command.

    yes, PostgreSQL supports NOTIFY and Qt can subscribe to them. But there are two problems with this:

    1) TRIGGER work only on tables, not on VIEWS, which means, the NOTIFY would have to be sent by the base tables instead of the aggregate VIEW. But because the base tables can change during runtime (REPLACE VIEW), this means a "management overhead"

    2) much more important: while PostgreSQL seems to be able to sent a NOTIFY not only with name, but also with payload, QtSQL seems to omit the payload. This means after a NOTIFY I would have to reread the complete VIEW instead of only updating the row which changed. This means, that the View(s) which depend on the model would have to be redrawn completely, instead of only updating the part which changed?

Similar Threads

  1. automatic reading TXT file
    By sunnysun520 in forum Qt Programming
    Replies: 10
    Last Post: 1st July 2009, 15:00
  2. Automatic UI Verification
    By binggan194 in forum Qt Programming
    Replies: 2
    Last Post: 3rd April 2009, 07:46
  3. automatic time and date updating
    By sudheer in forum Qt Tools
    Replies: 1
    Last Post: 17th January 2008, 10:00
  4. Automatic Splitter
    By Katuakina in forum Qt Tools
    Replies: 1
    Last Post: 5th October 2007, 09:29
  5. Automatic Resizing
    By ToddAtWSU in forum Qt Programming
    Replies: 7
    Last Post: 22nd January 2007, 18:41

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.