c++ - Qt Programming - QtConcurrence kill thread -


I use a QT console to run a function in a separate thread, but I stop, stop this thread Or want to kill but I'm not I have read it:

Note that QFuture does not support returning by QtConcurrent :: run (), canceling cancellations, or reporting progress.

Can I do it any other way?

My job is:

  void MainWindow :: on_imprimirButton_clicked () {if (filename.length () == 0) {ui- & gt; ConsolaBrowser- & gt; Annexe ("Error. Debe seleccionar un fichero") .; } And if (! Filename.contains (".txt")) {ui- & gt; ConsolaBrowser- & gt; Annexe ("Fichero error. Debe sextillar archive of G-CODE."); } Else {imprimiendo = 1; * Future = QtConcurrent :: Run (Imprimir, filename.toUtf8 (.) Data ()); Imprimiendo = 0; }} I think that the QtConcurrence solution is not very good. It is often suggested, but it is of no use with a good implementation with the threading library (for example, QtThread). The sample below shows a possibility to stop your thread. If you set the true m_bBreak truth in your main program, then the thread stops. In the same way you can also get the current thread progression.  
  int foo (bool * bStopper) {if (* bStopper) 0; // code back here 1; } Zero QThread :: Run () {m_iErrors = foo (& m_bBreak); // handle errors}  

Comments