Important: Please read the Qt Code of Conduct -

Common AppData folder error with special character

  • Hello,

    For my program (Qt MinGW 5.7 on Windows), I use a writable folder to store user parameters (to read and write).
    I use "QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);"

    It works on many computers with different Windows versions (I tried on 10 computers). However, with one computer, my program is not able to find the user's parameters. I investigated and found out that the username has a special character.
    The username is Andrée-Anne (a French name).
    The parameter location is "C:\Users\Andrée-Anne\AppData\Roamaing\MyProgram".

    However, the result of
    "qDebug() << QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);" is

    The character " é " is replaced by " Ú ". I guess this is why the program does not find the parameters.

    Any idea of what I could do ?? I know it's not a good idea to place special character anywhere but I must support my users who chose that...

    Thank you very much,


  • Lifetime Qt Champion

    @alecs26 Can you show the code where you use the path returned by QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);?
    The wrong output with qDebug could be an issue with console.

  • @jsulm thank you for your answer. Here is an example of write and read. They both work with every other computer but fail on this one.

    QString pathparam;
    pathparam = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/ParamBasic.txt";
    std::ofstream myfile;, std::ofstream::out | std::ofstream::trunc);
    myfile << p1 ;


    QString appparamfolderloc=QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/ParamBasic.txt";
    std::ifstream myfile(appparamfolderloc.toStdString());
        if (myfile.is_open())
            while (getline(myfile, line))
                std::stringstream os(line);
                os >> line2;

    Thanks !


  • Lifetime Qt Champion

    @alecs26 Why don't you use QFile?
    The problem could be pathparam.toStdString().
    Try with QFile without calling pathparam.toStdString() as QFile accepts QString.

  • @jsulm Thank you so so so much !! It works !
    I did not use QFile because I recycled a VStudio code for processing text file and I was too lazy to convert it in QFile. I should have done it !

    Thanks again,


Log in to reply