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. some problems with qpushbutton->setdisable
QtWS25 Last Chance

some problems with qpushbutton->setdisable

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 379 Views
  • 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.
  • gfxxG Offline
    gfxxG Offline
    gfxx
    wrote on last edited by
    #1

    I use setdisable true/false for "close" mouse event over a button after the User pressed action. I use a delay for renew the condition aver qpushbutton .... my simple code:

    
    void MainWindow::sendPause(bool paGen)
    {
            ui->GRun->setDisabled(true);
            if (paGen && (StIsOn1 && StIsRunning1)) {
                qDebug() << "xxxxx1";
                ui->Grun->setChecked(false);
                emit sendInOut(k::cm_pause_gen, true, 0);
            }
            else{
                qDebug() << "xxxxx2";
                ui->GPause->setChecked(false);
            }
            PauseResumeAutocheck();
    
    }
    
    void MainWindow::sendRun(bool paRun)
    {
            ui->Grun->setDisabled(true);
            if (paRun && (StIsOn1x && StIsRunning1x)) {
                qDebug() << "xxxxx3";
                ui->GPause->setChecked(false);
                emit sendInOut(k::cm_pause_gen, false, 0);
            }
            else{
                qDebug() << "xxxxx4";
                ui->GRun->setChecked(false);
            }
            PauseResumeAutocheck();
    
    }
    
    void MainWindow::PauseResumeAutocheck()
    {
        QTimer::singleShot(1200, [=]{ ui->Grun->setDisabled(false); ui->Gpause->setDisabled(false); qDebug() << "reset Pause Resume";});
    }
    

    The two qpushbutton is insert in a qgrouobox, and I set it as Autoexclusive.

    The code work not so good (some time the delay is not see) ... any how the event is equally propagated ... for example:

    1. I press GPause -> emit signal is ok
    2. qDebug messages is print
    3. the delay is ok ...
    4. I press GRun -> emit signal is ok
    5. qDebug messages is print
    6. for test I try to press GPause immediately after press GRun -> GPause not change BUT
    7. qDebug messages is print ... ????? Why these?????

    I hope someone can suggest my the right process to do these, because this obviuslly is not perfect working.

    regards
    Giorgio

    bkt

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      You use QTimer::singleShot - it is executed every time and you can't stop it from executing. Just use a QTimer object to have more control over it.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2

      • Login

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