Guest User

Untitled

a guest
Jan 16th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. def test():
  2. for x in range(100):
  3. print(x)
  4. print("python code !!!!")
  5.  
  6. test()
  7.  
  8. void SettingsWindow::on_pushButton_2_clicked()
  9. {
  10. QProcess process;
  11. QString scriptFile = QCoreApplication::applicationDirPath() + "/Users/wouterlefebvre/GithubRepos/Hello.py";
  12.  
  13. QString pythonCommand = "python " + scriptFile;
  14.  
  15. process.start (pythonCommand);
  16. QProcess *myProcess = new QProcess();
  17. myProcess->startDetached("python.exe "/Users/wouterlefebvre/GithubRepos/Hello.py" );
  18.  
  19. myProcess->start();
  20.  
  21. //check that the process actually starts
  22. if (!myProcess->waitForStarted()) {
  23. qDebug("Could not start process");
  24. return;
  25. }
  26.  
  27.  
  28. QTime time;
  29. time.start();
  30. //wait 4 seconds
  31. while (time.elapsed() < 4000) {
  32. //keep the GUI working
  33. QApplication::processEvents();
  34. }
  35.  
  36. myProcess->kill();
  37. // wait for the process to actually stop
  38. myProcess->waitForFinished();
  39.  
  40. delete myProcess;
  41.  
  42. }
Add Comment
Please, Sign In to add comment