Quantcast
Channel: Jobs
Viewing all articles
Browse latest Browse all 18427

How to control correctly an external Application(with a help of QProcess or anything else)

$
0
0
Hi, I have a NON-GUI application runnning as a Service on my device. Now I need some GUI-Application, where user can start and stop my Service, by pushing “start”- and “stop”-Buttons. As far as i understood, i can use QProcess for starting some external Applications from the current one. I made a little example GUI-Application, where i can start and close my NON-Gui-Service application. Everything works well, but not for my Requirements! When i close this GUI-Application, of course all processes i started within it -> in this case my Service-process will be killed. But i need to run my Service-process even after closing the GUI-Application. And kill it later when needed. In my case, my Service should run always and should be stopped just for resetting some options(what happens veeery seldom). I know its really simple requirement, but i cant find anything what i can use, or i just simply missing something. I dont know if its possible to implement what i want at all, and didnt found anything about killing Process with a known PID, so i’m confused if its even possible to do that. (i’m developing with QT 4.6.3, QtMobility 1.0.2 for nokia C05-00) I’m not sure if its needed but here is anyway how i start and stop my Service: BasicSettingsWidget::BasicSettingsWidget(QWidget *parent) :     QWidget(parent),     ui(new Ui::BasicSettingsWidget)    {       ui->setupUi(this);     geoServiceProcess = new QProcess(this);     QObject::connect(geoServiceProcess, SIGNAL(error(QProcess::ProcessError)),                       this, SLOT(processError(QProcess::ProcessError)));    }   ... void BasicSettingsWidget::on_startServiceBtn_clicked() {     if(geoServiceProcess){         geoServiceProcess->start("mg24GEO");     } }   void BasicSettingsWidget::on_stopService_clicked() {         if(geoServiceProcess){         if(geoServiceProcess->state() != QProcess::NotRunning)         {             if(geoServiceProcess->state() == QProcess::Starting)             {                 qDebug()<<"debug:QProcess::Starting";                 geoServiceProcess->waitForStarted();                 qDebug()<<"debug:QProcess::Starting-started";             }             qDebug()<<"debug:close QProcess ";             geoServiceProcess->close();             qDebug()<<"debug:waiting for finish";                       geoServiceProcess->waitForFinished();                      }else{             qDebug()<<"debug:QProcess::NotStarting";        }        qDebug()<<"debug:QProcess::stopped";     } } ... I would be glad about any help or tipp for my problem. Thank you in Advance!

Viewing all articles
Browse latest Browse all 18427

Trending Articles