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. [SOLVED] QWidget setVisible not executed?
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] QWidget setVisible not executed?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 1 Posters 3.7k 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.
  • M Offline
    M Offline
    maximus
    wrote on last edited by
    #1

    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


    Free Indoor Cycling Software - https://maximumtrainer.com

    1 Reply Last reply
    0
    • M Offline
      M Offline
      maximus
      wrote on last edited by
      #2

      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


      Free Indoor Cycling Software - https://maximumtrainer.com

      1 Reply Last reply
      0
      • M Offline
        M Offline
        maximus
        wrote on last edited by
        #3

        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]


        Free Indoor Cycling Software - https://maximumtrainer.com

        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