guidupas
14th February 2014, 20:44
Hello!
I am with a problem to increment the QProgressBar before starting the DB connection. Cde below
void defConexao::criaArquivoConfServidor(QString host, QString porta)
{
funcoesDB = new bancoDados;
bool retorno = true;
QSqlDatabase DB;
caixaMensagens mensagem;
this->barraProgresso->setMaximum(2);
this->barraProgresso->setMinimum(0);
int valorProgresso = 0;
if(!DB.isOpen())
{
DB = funcoesDB->adicionarBancoDados(DB);
valorProgresso = 1;
this->barraProgresso->setValue(valorProgresso);
}
if(funcoesDB->conectar(DB, host, porta))
{
qDebug() << "Conectou";
funcoesDB->fechar(DB);
valorProgresso = 2;
this->barraProgresso->setValue(valorProgresso);
}
else
{
mensagem.fecharMensagem("erro", "Banco de dados", "Não foi possÃ*vel conectar ao banco de dados");
this->barraProgresso->reset();
retorno = false;
}
}
The problem is that the progress bar does not set the value of the first function before it try to connect, that occurs in the second function. It sets all the values just before trying to connect. Why is that?
Thank you a lot.
I am with a problem to increment the QProgressBar before starting the DB connection. Cde below
void defConexao::criaArquivoConfServidor(QString host, QString porta)
{
funcoesDB = new bancoDados;
bool retorno = true;
QSqlDatabase DB;
caixaMensagens mensagem;
this->barraProgresso->setMaximum(2);
this->barraProgresso->setMinimum(0);
int valorProgresso = 0;
if(!DB.isOpen())
{
DB = funcoesDB->adicionarBancoDados(DB);
valorProgresso = 1;
this->barraProgresso->setValue(valorProgresso);
}
if(funcoesDB->conectar(DB, host, porta))
{
qDebug() << "Conectou";
funcoesDB->fechar(DB);
valorProgresso = 2;
this->barraProgresso->setValue(valorProgresso);
}
else
{
mensagem.fecharMensagem("erro", "Banco de dados", "Não foi possÃ*vel conectar ao banco de dados");
this->barraProgresso->reset();
retorno = false;
}
}
The problem is that the progress bar does not set the value of the first function before it try to connect, that occurs in the second function. It sets all the values just before trying to connect. Why is that?
Thank you a lot.