QProcess::pid returns Q_PID which is an OS-dependend typedef:

Qt Code:
  1. #if (!defined(Q_OS_WIN32) && !defined(Q_OS_WINCE)) || defined(qdoc)
  2. typedef qint64 Q_PID;
  3. #else
  4. QT_END_NAMESPACE
  5. typedef struct _PROCESS_INFORMATION *Q_PID;
  6. QT_BEGIN_NAMESPACE
  7. #endif
To copy to clipboard, switch view to plain text mode 

Is there a built-in way in Qt to obtain just the process ID number of a process, without resorting to OS-specific code? I came up with this utility function, but I'm surprised I can't find it in Qt itself:


Qt Code:
  1. quint64 getProcessID(const QProcess* proc)
  2. {
  3. #ifdef Q_WS_WIN
  4. struct _PROCESS_INFORMATION* procinfo = proc->pid();
  5. return procinfo->dwProcessId;
  6. #else // Linux
  7. return proc->pid();
  8. #endif // Q_WS_WIN
  9. }
To copy to clipboard, switch view to plain text mode