I want to save something in local directory at MyDocs/

This is my code,the first code below is correct and add and create txt and content to it.
However the second code went wrong.
Code:
QDir::setCurrent("/home/user/MyDocs/Documents/");   //Go to this directory
QFile file("lovenote_exp.txt");          //open file,all done correctly
    if (!file.open(QIODevice::WriteOnly|QIODevice::Append)) {
        qDebug()<< "Cannot open file for writing: " ;
        return;
    }

    QTextStream out(&file);
    out<<"\t"<<date<<"\t"<<title<<endl<<"\t"<<text<<endl;
   file.close();
The below is the second code, it went wrong.
Code:
QDir::setCurrent("/home/user/MyDocs/Documents/");   //Go to this directory
QString myfilename="myfile.txt";      // create a QString variant with this value.
QFile file(myfilename);          // this is the difference,it went wrong there
    if (!file.open(QIODevice::WriteOnly|QIODevice::Append)) {
        qDebug()<< "Cannot open file for writing: " ;
        return;
    }

    QTextStream out(&file);
    out<<"\t"<<date<<"\t"<<title<<endl<<"\t"<<text<<endl;
   file.close();
To be truth,i really dont know what went wrong ....But the second codes still didnt work .Anyone could help me???
It makes me confused.
Help!!!