Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QProgresBar and DB connection
Qt 6.11 is out! See what's new in the release blog

QProgresBar and DB connection

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 775 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • guidupasG Offline
    guidupasG Offline
    guidupas
    wrote on last edited by
    #1

    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.

    Att.
    Guilherme Cortada Dupas

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved