Use cd command in QT

1

Hi, I am trying to learn how to use commands in QT with cmd I can do the following:

QProcess consola;
consola.start("cmd.exe /C " + comando);
consola.waitForFinished();
consola.waitForReadyRead();

How can I do to use cd .. for example or cd to a location in my folder in QT.

    
asked by Perl 06.10.2016 в 15:23
source

2 answers

0

for that you must use the class QDir in this way you can access the directories and their contents.

When you have it, use the following functions to move between directories:

cd(const QString & dirName)
cdUp()

Or to create directories:

mkdir(const QString & dirName) const

To use the library do not hesitate to import-la:

#include <QDir>

Here I leave you all the information you may need: link

    
answered by 06.10.2016 / 16:09
source
0

You can use the QProcess::setWorkingDirectory method and I recommend using QProcess with setters, for example:

QProcess cmd;

QStringList argumentos;
argumentos << "/C" << comando;

cmd.setProgram("cmd.exe");
cmd.setArguments(argumentos);
cms.setWorkingDirectory("..") // o "../otrodirectiorio/relativo"
cmd.start(); // todos los parametros previamente "setteados"

So you can change the work folder, greetings!

    
answered by 21.09.2018 в 14:36