c++ - Refreshing a QSqlDatabase object's settings -
c++ - Refreshing a QSqlDatabase object's settings -
i have qt application (essentially) creates qmysql database connection using qsqldatabase, creates gridpopulator instance populate qtableview (obviously) info database. seems pretty simple, have preferences dialog, able alter database connection settings. so, if settings accepted within preferences dialog, application has utilize gridpopulator::refresh() repopulate qtableview. tried best explain process in diagram below.
the programme have able alter settings of database object so:
preferences p; p.read(); qsqldatabase databaseconnection = qsqldatabase::database("schedule_database"); databaseconnection.sethostname(p.database->server_addr); databaseconnection.setusername(p.database->username); databaseconnection.setpassword(p.database->password); databaseconnection.setdatabasename(p.database->database_name); databaseconnection.setport(p.database->serverport); it seems, though, not plenty refresh database connection. how create refresh process?
you need close() , open() connection after changing settings. written in documentation too.
c++ qt
Comments
Post a Comment