The Following 15 Users Say Thank You to sixwheeledbeast For This Useful Post: | ||
bingomion, Boemien, damagedspline, Estel, Fatalist, foobar, fw190, iceskateclog, imo, kent_autistic, marxian, mosiomm, sifo, Tiran, vi_ |
![]() |
2012-10-19
, 18:36
|
Posts: 138 |
Thanked: 90 times |
Joined on Mar 2012
|
#2
|
![]() |
2012-10-19
, 19:11
|
Posts: 2,292 |
Thanked: 4,135 times |
Joined on Apr 2010
@ UK
|
#3
|
void MainWindow::on_pushButtonStart_clicked() { QProcess process; process.start("sh /opt/tenminutecore/script/tenminutecore.sh"); } void MainWindow::on_pushButtonStop_clicked() { QProcess process; process.start("sh /opt/tenminutecore/script/kill.sh"); process.waitForFinished(); }
![]() |
2012-10-19
, 19:40
|
|
Posts: 1,986 |
Thanked: 7,698 times |
Joined on Dec 2010
@ Dayton, Ohio
|
#4
|
#!/bin/sh /opt/tenminutecore/script/tenminutecore.sh
process.start("yourscriptname.sh");
pid_t pid = fork(); if (pid == 0) { // We're inside the child process execl( "/bin/sh", "/bin/sh", "/opt/tenminutecore/script/tenminutecore.sh", NULL); } // If we reach this point, we are inside the parent process. // So, we'll wait for the child process to complete: int *stat_loc = NULL; waitpid(pid, stat_loc, 0);
The Following 3 Users Say Thank You to Copernicus For This Useful Post: | ||
![]() |
2012-10-19
, 20:09
|
Posts: 2,292 |
Thanked: 4,135 times |
Joined on Apr 2010
@ UK
|
#5
|
void MainWindow::on_pushButtonStart_clicked() { QProcess *process; process = new QProcess( this ); process->start("sh opt/tenminutecore/script/tenminutecore.sh"); } void MainWindow::on_pushButtonStop_clicked() { QProcess *process; process = new QProcess( this ); process->start("sh opt/tenminutecore/script/kill.sh"); process->waitForFinished(); }
The Following 3 Users Say Thank You to sixwheeledbeast For This Useful Post: | ||
![]() |
2012-10-19
, 20:28
|
|
Posts: 1,986 |
Thanked: 7,698 times |
Joined on Dec 2010
@ Dayton, Ohio
|
#6
|
Seems changing to this did the trick (pinched from Theme Customizer)
No idea why the first version didn't work.
The Following 3 Users Say Thank You to Copernicus For This Useful Post: | ||
![]() |
2012-10-19
, 21:16
|
|
Posts: 2,448 |
Thanked: 9,523 times |
Joined on Aug 2010
@ Wigan, UK
|
#7
|
private: QProcess *m_process;
#include <QApplication> #include <QDesktopWidget> ... connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(onOrientationChanged())); ... void MainWindow::onOrientationChanged() { QRect screen = QApplication::desktop()->screenGeometry(); if (screen.width() > screen.height()) { setLandscapeLayout(); } else { setPortraitLayout(); } } void MainWindow::setLandscapeLayout() { do stuff } void MainWindow::setPortraitLayout() { do stuff }
The Following 8 Users Say Thank You to marxian For This Useful Post: | ||
![]() |
2012-10-19
, 21:51
|
|
Posts: 1,359 |
Thanked: 1,292 times |
Joined on Oct 2011
@ Tartus.Syria
|
#8
|
![]() |
2012-10-19
, 23:33
|
|
Posts: 1,986 |
Thanked: 7,698 times |
Joined on Dec 2010
@ Dayton, Ohio
|
#9
|
Your old approach didn't work because the QProcess object fell out of scope.
The Following 2 Users Say Thank You to Copernicus For This Useful Post: | ||
![]() |
2012-10-19
, 23:53
|
|
Posts: 2,448 |
Thanked: 9,523 times |
Joined on Aug 2010
@ Wigan, UK
|
#10
|
Ah! So a "StartDetached()" call would work in that case, allowing the script to continue after the QProcess object is destroyed.
Actually, this also means you don't really need the "kill.sh" script to stop the process (unless kill.sh does something special). A call to "terminate()" (or just destroying the object) should do the trick...
The Following 3 Users Say Thank You to marxian For This Useful Post: | ||
![]() |
Tags |
bouldering, exercise, tenminutecore, training |
|
All information on the wiki page.
Wiki Admin
sixwheeledbeast's wiki
Testing Squad Subscriber
- mcallerx - tenminutecore - FlopSwap - Qnotted - zzztop - Bander - Fight2048 -
Before posting or starting a thread please try this.
Last edited by sixwheeledbeast; 2014-04-26 at 15:32. Reason: Updated to 0.0.8