Vote count:
0
Im my program, I am using Qprocess function, while executing this program will play the wave signal. But the application is creating two more process PID with same application name & that two process will not be terminating. kindly help me how to solve this problem.
I am using QT 4.8.1 version & Linux 2.6.36.4 armv5tejl GNU/Linux
Kindly attached my code & oputput
**********************************
widget.cpp
**********************************
#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget)
{
qDebug() << "Application Started";
ui->setupUi(this);
setWindowFlags(Qt::FramelessWindowHint);
playwave = new QProcess();
}
Widget::~Widget()
{
delete ui;
}
void Widget::keyReleaseEvent(QKeyEvent *k) {
k->accept();
int key = k->key();
qDebug() << "Key Release Event Key = " << key;
if (key == 16777220) {
qDebug() << "Play welcome";
playwave->startDetached("aplay /opt/WavFiles/English/welcome.wav");
qDebug() << "Play completed";
}
}
**********************************
widget.h
**********************************
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <QDebug>
#include <QKeyEvent>
namespace Ui {
class Widget;
}
class Widget : public QWidget {
Q_OBJECT
public:
Widget(QWidget *parent = 0);
~Widget();
QProcess *playwave;
protected:
void keyReleaseEvent(QKeyEvent *k);
private:
Ui::Widget *ui;
};
#endif // WIDGET_H
**********************************
Output
*************
Application Started
Play welcome
Play completed
Playing WAVE '/opt/WavFiles/English/welcome.wav' : Signed 16 bit Little Endian, Rate 8000 Hz, Stereo
PID USER TIME COMMAND
460 root 0:00 ./process -qws
462 root 0:01 ./process -qws
463 root 0:00 ./process -qws
asked 39 secs ago
Multiple PID for qprocess function
Aucun commentaire:
Enregistrer un commentaire