command prompt command execution in Qt
-
wrote on 17 Aug 2018, 10:17 last edited by
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 folderThank you in Advance.
-
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 folderThank you in Advance.
wrote on 17 Aug 2018, 10:26 last edited byAny one here ?
-
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 folderThank you in Advance.
wrote on 17 Aug 2018, 10:31 last edited by JonBQProcess::execute("gedit my.txt")
QProcess::execute("mkdir folder")
In practice you should probably use the http://doc.qt.io/qt-5/qprocess.html#execute overload to pass the argument(s) as a
QStringList
.P.S.
To create a folder, don't actually use a sub-process ofmkdir
, use the in-built Qt function for creating a directory. -
Any one here ?
wrote on 17 Aug 2018, 10:32 last edited by JonB@Pranit-Patil said in command prompt command execution in Qt:
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...
-
QProcess::execute("gedit my.txt")
QProcess::execute("mkdir folder")
In practice you should probably use the http://doc.qt.io/qt-5/qprocess.html#execute overload to pass the argument(s) as a
QStringList
.P.S.
To create a folder, don't actually use a sub-process ofmkdir
, use the in-built Qt function for creating a directory.wrote on 17 Aug 2018, 10:36 last edited by@JonB
i m doing simply like this but not getting o/pQProcess process;
QString exePath = "C:/Windows/ystem32/cmd.exe";
process.start(exePath);
process.execute("cmd.exe"); -
@JonB
i m doing simply like this but not getting o/pQProcess process;
QString exePath = "C:/Windows/ystem32/cmd.exe";
process.start(exePath);
process.execute("cmd.exe");wrote on 17 Aug 2018, 10:38 last edited by JonB@Pranit-Patil
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. -
@Pranit-Patil
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.wrote on 17 Aug 2018, 10:43 last edited by@JonB sorry for that
i tried your examples
QProcess::execute("gedit my.txt");
QProcess::execute("mkdir Test");but not getting any error or any output.
-
@JonB sorry for that
i tried your examples
QProcess::execute("gedit my.txt");
QProcess::execute("mkdir Test");but not getting any error or any output.
wrote on 17 Aug 2018, 11:01 last edited by JonBNeither 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 needQProcess::execute("cmd /c mkdir Test");
. -
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 needQProcess::execute("cmd /c mkdir Test");
.wrote on 17 Aug 2018, 11:45 last edited by@JonB Im Developing application in Qt creator 4.6.0 on windows 7 -32bit
#include <QProcess>
#include <QDir>
void Command::on_pushButton_clicked()
{
QProcess process;
QString exePath1 = "D:/Phoenix";
process.start(exePath1);
process.execute("cmd /c mkdir test");
}
not getting any output. -
@JonB Im Developing application in Qt creator 4.6.0 on windows 7 -32bit
#include <QProcess>
#include <QDir>
void Command::on_pushButton_clicked()
{
QProcess process;
QString exePath1 = "D:/Phoenix";
process.start(exePath1);
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);
-
@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);
wrote on 17 Aug 2018, 11:59 last edited by JonB@jsulm
I already pointed all this stuff to OP above.
Additionally, I also deliberately usedQProcess::execute()
in my examples for him to keep it down to one liners. Each time he has also added an additionalQProcess::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 :) -
@jsulm
I already pointed all this stuff to OP above.
Additionally, I also deliberately usedQProcess::execute()
in my examples for him to keep it down to one liners. Each time he has also added an additionalQProcess::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 :)wrote on 17 Aug 2018, 12:16 last edited by@JonB
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
-
@jsulm
I already pointed all this stuff to OP above.
Additionally, I also deliberately usedQProcess::execute()
in my examples for him to keep it down to one liners. Each time he has also added an additionalQProcess::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 :)wrote on 17 Aug 2018, 12:27 last edited by
1/13