Important: Please read the Qt Code of Conduct -

[SOLVED] QFile open in text mode error.

  • I've got some text file in some text path, but when I try to open it in ReadOnly and Text mode fuction open returns false. Here is the code:
    @#define XML_FOLDER "Data"

    QString path = QString(""%1%2%3%2%4"").arg(QApplication::applicationDirPath()).arg(QDir::separator()).arg(XML_FOLDER).arg("Changelog.txt");
    path = QDir::fromNativeSeparators(path);

    QFile file(path);

    if (! | QIODevice::Text)) {
    QMessageBox::warning(this, tr("File not found"), QString("%1\n%2").arg(tr("Can't find changelog file!")).arg(path));

    When I look at path variable value it's equal : "D:/Projects/sxAssc/Desktop/sxConfigAssc/Debug/Data/Changelog.txt" . I have a file in this path with such name and read/write premitions for all. Is it bug on 4.8.3 qt version on Windows platform or thomething else ?

  • You can't have any files in this path, you can't even have such kind of paths in windows, because path can't start with quote symbol(")


    should be


  • Thanks, AcerExtensa. Now it works.

Log in to reply