title: Executing a signal after event loop
body: <p>In my .qml file, when a <code>Button</code> is pressed, it emits a signal, and some action is taken. This action takes a long time (it is encrypting data) and I want the button to "unpush" itself before this action starts, so I can show a progress bar on top. </p>
  
  <p>I know Qt has event loop, and somehow, I need this signal to be emitted after this event loop , or when the GUI completes the Paint() of all objects, so the button is shown unpressed.</p>
  
  <p>How is this done?</p>
  
  <p>This is the code that is being executed on the signal, the heavy process is <code>aewm_obj.save_account(key,account)</code> , it takes 2 seconds on desktop PC and 10 seconds on Android:</p>
  
  <pre><code>function save_account() {
      if (fld_password1.length===0) {
          if (account.type==WalletAccount.WACCT_TYPE_FULL) {
              return
          }
      }
  
      if (fld_password1.text!==fld_password2.text) {
          console.log("passwords do not match")
      } else {
          btn_save.enabled=true;
          if (account.type==WalletAccount.WACCT_TYPE_FULL) {
              key.password=fld_password1.text
              account.password=fld_password1.text
          }
          btn_save.enabled=false
          encrypting_message.open()
          if (aewm_obj.save_account(key,account)) {
              encrypting_message.close()
              accounts_root.back_to_accounts()
          } else {
              encrypting_message.close()
          }
      }
  }
  </code></pre>
  
  <p>The problem is, the dialog with the progress bar is shown after the heavy process finishes, however it was called before. This happens because the event loop to show and hide components is processed too late.</p>