View Full Version : Problem with QDir::mkdir() and vector of QStrings
legolizard
9th July 2012, 18:18
I have a problem with QDir::mkdir().
I have a vector of QStrings and would like to make a new directory (in a given folder) named off of one of the QStrings in the vector, however, it fails to do so. Code:
QDir dir(/*path*/);
QString newPath = rawData[ 9 ];// rawData is the vector of QStrings
dir.mkdir( newPath );
When I output newPath, everything is okay, yet Qdi::mkdir fails for no apparent reason. T_T
Any help would be greatly appreciated. :D
mvuori
9th July 2012, 18:50
Even though there is no apparent reason, apparently there is a reason... It might be something hard to notice, like a trailing newline or other invisible character -- which is why people should always post some more code than where the problem exhibits. It is a question of how the variable & data has been created.
legolizard
9th July 2012, 19:07
No, I have outputed rawData[9] as well, whilst debugging, and it is exactly what it should be. In fact I have outputted the entire vector, and everything is correct. If you would like me to post some more code then sure. : )
I input into the vector with this function:
signed int FileSystem::readFromFile(){
std::string tmp = selectedFilePath.toStdString();//selectedFilePath is a QString of file path I am going to read. It is initalized else where in the program.
std::ifstream ifs;
ifs.open( tmp.c_str() );
if( ifs.is_open() ){
while( getline( ifs , tmp ) ){
if(rawData.size() < MAX_LINES){ // Max_SIZE is a constant I define elsewhere in the program.
rawData.push_back( QString::fromStdString( tmp ) );//Enter data into vector.
}
}
return EXIT_SUCCESS;
}
else return EXIT_FAILURE;
}
Again, I have outputted the vector and everything is correct. It is quite confusing. :/
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.