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

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -