[Qt-interest] How to make the Button response quickly?

André Somers andre at familiesomers.nl
Sun Mar 1 17:14:34 CET 2009


Hi,

"Kermit Mei" <kermit.mei at gmail.com> schreef in bericht 
news:49AAAC96.1090601 at gmail.com...
> Hello, When I click the button(a common QPushButton), slot pronounce()
> will be called. It is defined as the following:
>
> void ScannerWidget::pronounce(){
>    QDir wordPath(realPeople.absolutePath().append("/").append(word[0]));
>    qDebug(wordPath.absolutePath().toStdString().c_str());
>    QProcess::execute(playCmd,
>            QStringList(wordPath.absoluteFilePath(word+".wav")));
> }
>
> When the words be pronouncing by another program called by QProcess,
> the button which I clicked is "down" (I can't clicked it whthin a short 
> time),
> and it must wait for process, then it can "up".
>
> How can I make the pushButton "up" as well as the others ?
> And,  in fact, I just want to pronounce a word when the last haven't 
> finished.

The documentation on QProcess::execute reads:
"Starts the program program with the arguments arguments in a new process, 
WAITS FOR IT TO FINISH, and then returns the exit code of the process. Any 
data the new process writes to the console is forwarded to the calling 
process." (Caps are mine)

You want to have asynchronous execution. Maybe QProcess::startDetached is 
what you are after?

André

 




More information about the Qt-interest-old mailing list