I would like to start a process when I click on a button on my Qt application.
I created a process with QProcess::startDetached(..., qint64 * pid)
(http://doc.qt.io/qt-5/qprocess.html#startDetached) but I have a console that I would like to hide.
How to hide it? Which function must I to use outside the process?
This code doesn't hide the console of my process (in win32):
if (AttachConsole((DWORD)m_PID))
{
FreeConsole();
}
If you can recompile the program you are starting, you might make it a Windows rather than console program (in MSVC this is in the projects linker->system, settings, you want
/SUBSYSTEM:WINDOWS
).Else the QT
start
method apparently never creates a console window, whilestartDetached
does, so it might be possible for you to usestart
depending on your use.Alternatively the
CREATE_NO_WINDOW
flag forCreateProcess
will prevent the automatic console, quote MSDN:Unfortunately it does not look like QT provides any way to create or use its
QProcess
with native flags or from a native handle (e.g. noQProcess process(CreateProcess(...))
), allthough it was suggest some years back and rejected. QProcess: Make it possible to set native process creating flagsSo you would either have to just use the Microsoft API's or find another library for multi-process work.