PDA

View Full Version : dynamically create folders with QT



eleanor
13th March 2007, 07:58
Hey you guys.

Is it possible to create folder's during runtime (what I mean is that the program creates folders inside the current directory (so basically they are sub-folders) based on the current date).

Let's say it's 22.10.2005 today. And the program would create a sub-folder with a name 22.10.2005 inside the current directory.

Is that possible...

Any hints are appreciated.

wysota
13th March 2007, 08:23
Yes, of course it is possible. QDir::mkdir() or QDir::mkpath() are the way to go.

eleanor
13th March 2007, 11:35
Hey. Thanks for your reply.

Can you tell me one more thing. Why does this code not work:


void MojeOkno::vpisiVpisaneVrednosti() {
QFile file("test.txt");

QTextStream out(&file);
out << "Let's see if it works." << endl;
file.close();
}

It does not save the string in test.text.

high_flyer
13th March 2007, 11:40
you forgot to open the file:



void MojeOkno::vpisiVpisaneVrednosti() {
QFile file("test.txt");
file.open(QFile::WriteOnly | QFile::Truncate);
QTextStream out(&file);
out << "Let's see if it works." << endl;
file.close();
}