Dear All
I have written a small class called MYSQL_DB which deals with all the steps required for QMYSQL (QtSql) with the database parameters being passed from another class. The following function should disable all QPushButton's, print a line to QTextEdit telling the user that the database connection routine is running and then instantiate the MYSQL_DB class and call one of its methods.
All this code works exactly as designed but with one major problem. The code at lines 4,5,6 and the QTextEdit->insertPlainText at line 15 does not run until the MYSQL_DB class has completed.
I cannot understand why this should be. Cam anybody help me with this dilemma?
Many thanks
Ishtar
void Dialog_Configure::connectDB(){
// Disable all buttons
ui->buttonOK->setEnabled(false);
ui->buttonCancel->setEnabled(false);
ui->buttonConnect->setEnabled(false);
//Grab credentials from QLineEdit
QString DB_IPAddress
= ui
->lineIPAddress
->text
();
int DB_PortAddress = ui->linePort->text().toInt();
QString DB_UserName
= ui
->lineUserName
->text
();
QString DB_Password
= ui
->linePassword
->text
();
ui->textEditDBStatusLog->insertPlainText("Connecting...\n\n"); // Add text to QTextEdit informing user of the initilised connection
// Instantiate an instance of MySQL_DB class
MySQL_DB connectionTest;
// Call connectionTest method of the MySQL_DB Class returning QString status
QString connectionStatus
= connectionTest.
connectionTest(DB_IPAddress, DB_PortAddress, DB_UserName, DB_Password
);
// Add SQL connection result into QTextEdit
ui->textEditDBStatusLog->insertPlainText(connectionStatus);
}
void Dialog_Configure::connectDB(){
// Disable all buttons
ui->buttonOK->setEnabled(false);
ui->buttonCancel->setEnabled(false);
ui->buttonConnect->setEnabled(false);
//Grab credentials from QLineEdit
QString DB_IPAddress = ui->lineIPAddress->text();
int DB_PortAddress = ui->linePort->text().toInt();
QString DB_UserName = ui->lineUserName->text();
QString DB_Password = ui->linePassword->text();
ui->textEditDBStatusLog->insertPlainText("Connecting...\n\n"); // Add text to QTextEdit informing user of the initilised connection
// Instantiate an instance of MySQL_DB class
MySQL_DB connectionTest;
// Call connectionTest method of the MySQL_DB Class returning QString status
QString connectionStatus = connectionTest.connectionTest(DB_IPAddress, DB_PortAddress, DB_UserName, DB_Password);
// Add SQL connection result into QTextEdit
ui->textEditDBStatusLog->insertPlainText(connectionStatus);
}
To copy to clipboard, switch view to plain text mode
Bookmarks