Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Notification when database changes
Forum Updated to NodeBB v4.3 + New Features

Notification when database changes

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Schluchti
    wrote on last edited by
    #1

    Hi,

    I wrote a QT desktop application which is used by different people. The application consits of several complex widgets which are aligned in a QTabBar. Every time the user clicks a tab, the model of the underlying widget fetches data from the database and populates the model. However, due to the complexity of the database queries, this takes some time.

    I want to change this approach, so that the models are only populated once (typically at startup) and then these "local" models are used. If a user changes something, the "local" model get's changed and the changes are also written back to the database. However, as I mentioned before, the application is used by different people on different machines. So if User B changes something in the application on his machine, I want to reload the corresponding widget in User A's application.

    How can I accomplish that in QT?

    I know that it is possible to emit an asynchronous signal with PostgreSQL which can be captured with QT, but unfourtanely I have to use SQL Server.

    The only solution I came up with is, to use a thread and periodically check if there are changes in the database. If that's the case, I re-populate the appropriate model. Is this the way to go here or exists there a more elegant solution to this?

    Thanks for your help!

    Kind Regards
    Bernhard

    Want to read more about Qt?

    https://gympulsr.com/blog/qt/

    Latest Article: https://gympulsr.com/blog/qt/2017/06/14/ios-background-music-qt.html

    1 Reply Last reply
    0
    • hskoglundH Offline
      hskoglundH Offline
      hskoglund
      wrote on last edited by
      #2

      Hi, I'm having a bit of the same design problem, working with a healthcare app that also has to support legacy SQL Servers. In my case I want it to work also on Macs and Linux, so I'm stuck with Qt's vanilla QSqlDatabase and QSqlDriver. And when I query the driver for ::hasFeature(EventNotifications) it returns false :-( (but true for PostgreSQL).

      So I guess I'm stuck with periodical polling.

      But in your case, if you're on Windows only, I know for example .NET supports "SQLServer's Query Notifications":http://msdn.microsoft.com/en-us/library/ms130764.aspx So it should be possible to add this functionality with a Qt plugin or .dll.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved