[SOLVED] QWidget setVisible not executed?



  • I have a QPushButton that is connected to a function "login" :
    @connect(ui->loginButton, SIGNAL(clicked()), this, SLOT(login()) );@

    At the start of the login function, I set a QWidget visible (to show that application is loading) and right before going out of the login function, I hide this widget. My problem is that the widget never get visible. Is there something that i'm not seeing, it's just a procedural function, I dont' think I need thread for that?

    Here is my login function :
    @void DialogLogin::login() {

    setLoadingInterface(true);
    
    QString username = ui->lineEdit_username->text();
    QString pw = ui->lineEdit_pw->text();
    
    bool loginAccepted = loginHelper(username, pw);
    
    if (loginAccepted) {
        QDialog::accept();
    }
    else {
        QDialog::rejected();
    }
    setLoadingInterface(false);
    

    }

    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    void DialogLogin::setLoadingInterface(bool enabled) {

    qDebug() << "change button state: " << enabled;
    ui->loginButton->setEnabled(!enabled);
    labelLoading->setVisible(enabled);
    ui->loginButton->repaint();
    labelLoading->repaint();
    if (enabled)
        disconnect(ui->loginButton, SIGNAL(clicked()), this, SLOT(login()) );
    else
        connect(ui->loginButton, SIGNAL(clicked()), this, SLOT(login()) );
    

    }
    @

    Log:
    change button state: true
    LOG: "SELECT id, username, first_name, last_name, birthdate, sex, email, weight, height, FTP, LTHR, KM_done FROM user WHERE BINARY username='fdsafs'"
    Bad password or username
    change button state: false



  • found some answers here:
    http://qt-project.org/forums/viewthread/4780

    But it still not working as expected, even when the button is gray, I can click on it, resulting in 2 query to the database... I updated the code up here



  • Apparently the GUI Thread is stuck and nothing can by-pass that.

    I saw some people suggesting running an external QProcess that show a loading animation and block the application, what?! there must a better way to do that? I mean blocking a button waiting for an action to finish is a common task...

    [Edit: It seems I can put my SqlQuery in a thread in order to liberate the UI.. working on it:
    http://www.linuxjournal.com/article/9602?page=0,2]


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.