int main(int argc, char *argv[]){ Q_INIT_RESOURCE(application); QApplication app(argc, argv); QSqlDatabase db = QSqlDatabase::addDatabase( "QMYSQL", "mconn" ); db.setDatabaseName( "xxxxx" ); db.setUserName( "xxxxx" ); db.setPassword( "xxxxx" ); db.setHostName( "xxxxxxx" ); if ( !db.open() ) { QMessageBox::critical(NULL,"Error connect",db.lastError().text()); return FALSE; };QSqlDriver *driver = db.database().driver();if (driver->hasFeature(QSqlDriver::EventNotifications)){ app.connect(db.driver(), SIGNAL(notification(const QString&)), &app, SLOT(slotRefresh()));} else QMessageBox::critical(0,"notify","Банан!!!!!!!");
C++ (Qt)bool QMYSQLDriver::hasFeature(DriverFeature f) const{ switch (f) { case Transactions:// CLIENT_TRANSACTION should be defined in all recent mysql client libs > 3.23.34#ifdef CLIENT_TRANSACTIONS if (d->mysql) { if ((d->mysql->server_capabilities & CLIENT_TRANSACTIONS) == CLIENT_TRANSACTIONS) return true; }#endif return false; case NamedPlaceholders: case BatchOperations: case SimpleLocking: case EventNotifications: // <----------- case FinishQuery: return false; case QuerySize: case BLOB: case LastInsertId: case Unicode: case LowPrecisionNumbers: return true; case PreparedQueries: case PositionalPlaceholders:#if MYSQL_VERSION_ID >= 40108 return d->preparedQuerysEnabled;#else return false;#endif case MultipleResultSets:#if MYSQL_VERSION_ID >= 40100 return true;#else return false;#endif } return false;}