qt mysql nodification

来源:互联网 发布:新浪微博数据库 编辑:程序博客网 时间:2024/05/16 08:25

Wouldn’t it be nice if your database could tell you that somethingit thinks you should know about just happened? For example that arecord was inserted, modified or deleted from your favorite table.Well, some databases actually can and as of Qt 4.4 you may be able totake advantage of this in your Qt applications.

Imagine an asynchronous event notification as a signal emitted fromthe database to announce the occurrence of a specified condition oraction. The message can be posted automatically from a trigger or astored procedure, or even manually from a shell. The message is verylightweight: nothing more than a string containing the name of theevent that occurred.

To subscribe to an event just use QSqlDriver::subscribeToNotification(). When an event that you’re subscribing to is posted by the database the driver will emit the notification() signal and your application can take appropriate action.

Currently this feature is only supported by the PostgreSQL andInterbase/Firebird drivers, but support may be added to other driversin the future. Use QSqlDriver::hasFeature() to check whether the feature is available or not in the driver you’re using.

If you can’t wait until Qt 4.4 to start hacking with asynchronous database events they are already available in the snapshots.

原创粉丝点击