PDA

View Full Version : QDir::setCurrent



RegMe
3rd June 2016, 10:21
Hi,

I can't change the working directory using Qdir::setCurrent, it returns false
I used it with QProcess


QProcess process;
QString cloneProject;
bool cloneOk = false;
QString dir = path;

qDebug() << QDir::current();

QDir::setCurrent(dir);
QDir directory(dir);
qDebug() << QDir::current();

cloneProject = "git clone ssh://user@host:port/"+project+".git";
process.start(cloneProject);

anda_skoa
3rd June 2016, 10:37
Is "path" a valid directory?

Also, why change your program's current working directory if you want to change the one of the QProcess?

Cheers,
_

RegMe
3rd June 2016, 11:01
qDebug() << QDir::current();

QDir::setCurrent(dir);
QDir directory(dir);

qDebug() << directory;

qDebug() << QDir::current();

cloneProject = "git clone ssh://user@host:port/"+project+".git";
process.start(cloneProject);

Console out :
QDir( "/home/.../key/bin" , nameFilters = { "*" }, QDir::SortFlags( Name | IgnoreCase ) , QDir::Filters( Dirs|Files|Drives|AllEntries ) )
QDir( "/home/.../Plg_mgm" , nameFilters = { "*" }, QDir::SortFlags( Name | IgnoreCase ) , QDir::Filters( Dirs|Files|Drives|AllEntries ) )
QDir( "/home/.../key/bin" , nameFilters = { "*" }, QDir::SortFlags( Name | IgnoreCase ) , QDir::Filters( Dirs|Files|Drives|AllEntries ) )

Added after 7 minutes:

Thanks, the problem is solved

Problem was in the path creation