Qt Creator Disable push button when precessed -
i'm new using qt , i'm having troubles it.
i'm doing simple terminal application , need disable buttons few seconds after selected.
i'm doing this:
void mainwindow::on_readcard_clicked(){ this->setenabled(false); //send command qstring commandstring = ""; commandstring.append('1'); commandstring.append("\n"); qbytearray commandarray = commandstring.tolocal8bit(); serial->write(commandarray); //read card qbytearray info = serial->readline(12); qstring datastring = 0; datastring.append(data); ui->cardnumber->settext(datastring); datastring.clear(); data.clear(); qbytearray saldo = serial->readall(); qstring saldostring = 0; saldostring.append(saldo); ui->balance->settext(saldostring); saldostring.clear(); saldo.clear(); this->setenabled(true);}
i need because if press button twice before finished processing first tap "crazy" array lots of trash. tried utilize "waitforbyteswritten" , "waitforreadyread" hasn't blocked connection until processed.
regards
try qtimer::singleshot() :
this->setenabled(false); qtimer::singleshot(2000, this, slot(enablemybutton())); // code void enablemybutton() { this->setenabled(true); }
it'll enable button 2secs after call
qt
No comments:
Post a Comment