Important: Please read the Qt Code of Conduct -

[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() {

    QString username = ui->lineEdit_username->text();
    QString pw = ui->lineEdit_pw->text();
    bool loginAccepted = loginHelper(username, pw);
    if (loginAccepted) {
    else {


    void DialogLogin::setLoadingInterface(bool enabled) {

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


    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:

    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:,2]

Log in to reply