Hello


I have a small example:

main.cpp
Qt Code:
  1. #include <QtCore/QCoreApplication>
  2. #include "process.h"
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6. QCoreApplication a(argc, argv);
  7. Process *proc = new Process;
  8. proc->startProcess();
  9.  
  10. return a.exec();
  11. }
To copy to clipboard, switch view to plain text mode 


process.h
Qt Code:
  1. #ifndef PROCESS_H
  2. #define PROCESS_H
  3.  
  4. #include <QProcess>
  5.  
  6. class Process : public QProcess
  7. {
  8. public:
  9. Process();
  10. void startProcess();
  11. };
  12.  
  13. #endif // PROCESS_H
To copy to clipboard, switch view to plain text mode 

process.cpp
Qt Code:
  1. #include "process.h"
  2. #include <QDebug>
  3. #include <QDir>
  4. #include <QFileInfo>
  5. #ifdef Q_WS_WIN
  6. #include <windows.h>
  7. #endif
  8.  
  9. Process::Process()
  10. {
  11.  
  12. }
  13. void Process::startProcess()
  14. {
  15.  
  16. #ifdef Q_WS_WIN
  17.  
  18. qDebug() << "Bin dran!";
  19.  
  20. QString fileName = "69874.ods";
  21.  
  22. fileName = QDir::tempPath() + "/" + fileName;
  23. QFileInfo fileInfo(fileName);
  24.  
  25. this->start(QString("rundll32 url.dll,FileProtocolHandler \"%1\"").arg( fileInfo.absoluteFilePath()));
  26.  
  27. struct _PROCESS_INFORMATION *procInfo = this->pid();
  28.  
  29. qDebug() << "PID: " << procInfo->dwProcessId;
  30.  
  31. #endif
  32.  
  33. #ifndef Q_WS_WIN
  34.  
  35. #endif
  36. }
To copy to clipboard, switch view to plain text mode 

i want to open a document (works fine) and get the process for (in my case) for soffice/excel. But qt returned another pid (i think its the qprocess pid and not soffice).

We have a client-server architecture and i want to write back the file to the server if the editor is closed.

Is there a way to get the PID from the childprocess?

proc->state() returned always is runned.