Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
command prompt command execution in Qt
How command prompt command execution in Qt application
like in case of - gedit my.txt in command prompt my.txt file be open to edit
in case of - mkdir Qt in command prompt i have to execute this command and want to create folder
Thank you in Advance.
Any one here ?
In practice you should probably use the http://doc.qt.io/qt-5/qprocess.html#execute overload to pass the argument(s) as a
To create a folder, don't actually use a sub-process of
mkdir, use the in-built Qt function for creating a directory.
Any one here ?
You posted that 9 minutes after your original query. Do you pay for my support, or anyone else's, within 10 minutes? :( Or do you just think it's my/our duty? In which case I'll leave it to others for you from now on...
i m doing simply like this but not getting o/p
QString exePath = "C:/Windows/ystem32/cmd.exe";
I gave you the lines to type for your question. If you choose to do something quite different and wrong, that's up to you. Perhaps others will sort you out.
@JonB sorry for that
i tried your examples
but not getting any error or any output.
Neither command should produce any error or output. Unless you don't even have
gedit.... And if you're Windows (your question does not even mention the OS), you may need
QProcess::execute("cmd /c mkdir Test");.
@JonB Im Developing application in Qt creator 4.6.0 on windows 7 -32bit
QString exePath1 = "D:/Phoenix";
process.execute("cmd /c mkdir test");
not getting any output.
@Pranit-Patil "not getting any output." - what "output" do you expect?
Why do you start new process to create a directory? You can do this way faster and easier with Qt (http://doc.qt.io/qt-5/qdir.html#mkdir)
Also this does not make any sense:
QProcess process; QString exePath1 = "D:/Phoenix"; process.start(exePath1); process.execute("cmd /c mkdir test");
You can't start a directory as it is not an executable. There is no need to use both start() AND execute().
Did you actually read QProcess documentation?!
It has a nice example:
QString program = "./path/to/Qt/examples/widgets/analogclock"; QStringList arguments; arguments << "-style" << "fusion"; QProcess *myProcess = new QProcess(parent); myProcess->start(program, arguments);
I already pointed all this stuff to OP above.
Additionally, I also deliberately used
QProcess::execute()in my examples for him to keep it down to one liners. Each time he has also added an additional
QProcess::start(). I suggested he just copy my examples verbatim to avoid this, but we don't seem to be getting anywhere.... I'll leave it to you :)
Thank you for your reply
Sorry sir i didn't understand what your saying ..?
aim - create folder in my system using commands of cmd prompt in any location through QT application.
Im new in Qt i don't have more knowledge on it plz suggest