c++ - Changing current path of a Qt Application -


i using qt library , want set current path path contained in qstring oldconfigfilename , using setcurrent() setcurrent returning false value indicating failure in changing path. code:

qstring path = qdir::currentpath(); std::string currentpath  = path.tostdstring(); std::string configpath = oldconfigfilename.tostdstring(); bool res = qdir::setcurrent(oldconfigfilename); if(res)  {     qdebug() << "path changed";  } else {   qdebug() << "path not changed"; } 

the problem path using full path config file containing file name. when try change directory path command fail because oldconfigfilename file not existing folder. simple way fix use qfileinfo remove filename part path use directory.

qfileinfo fi(oldconfigfilename);  bool res = qdir::setcurrent(fi.path());  if(res)  {     qdebug() << "path changed";  } else {   qdebug() << "path not changed"; } 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -