Ok, just a second. Did you mean this chunk of code:
//connect to database
db.setHostName(host);
db.setDatabaseName(db_name);
db.setUserName(db_user);
db.setPassword(db_pass);
//get a pointer to a database connection
m_pDatabase = &QSqlDatabase::database();
Q_CHECK_PTR(m_pDatabase);
//sql table model == read/write model --> navigate and modify individual sql tables
Q_CHECK_PTR(m_pModel);
//model->setTable(db_table);
//all changes will be cached in the model until either submitAll() or revertAll() is called
//populates the model with data from the table, using the specified filter and sort conditions
//model->select();
}
//QSqlDatabase* MySQLConnect::m_pDatabase=0;
/*
//this function is called if a refresh button is clicked
void MySQLConnect::refresh_everything() {
model->select();
}
void MySQLConnect::change_mysql() {
//submits all pending changes to the mysql database
model->submitAll();
}
*/
MySQLConnect::MySQLConnect(QString db_user, QString db_pass, QString db_name, QString host, QString type) {
//connect to database
QSqlDatabase db = QSqlDatabase::addDatabase(type);
db.setHostName(host);
db.setDatabaseName(db_name);
db.setUserName(db_user);
db.setPassword(db_pass);
//get a pointer to a database connection
m_pDatabase = &QSqlDatabase::database();
Q_CHECK_PTR(m_pDatabase);
//sql table model == read/write model --> navigate and modify individual sql tables
m_pModel = new QSqlRelationalTableModel(this);
Q_CHECK_PTR(m_pModel);
//model->setTable(db_table);
//all changes will be cached in the model until either submitAll() or revertAll() is called
m_pModel->setEditStrategy(QSqlTableModel::OnManualSubmit);
//populates the model with data from the table, using the specified filter and sort conditions
//model->select();
}
//QSqlDatabase* MySQLConnect::m_pDatabase=0;
/*
//this function is called if a refresh button is clicked
void MySQLConnect::refresh_everything() {
model->select();
}
void MySQLConnect::change_mysql() {
//submits all pending changes to the mysql database
model->submitAll();
}
*/
To copy to clipboard, switch view to plain text mode
Bookmarks