Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] QFile open in text mode error.
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] QFile open in text mode error.

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anticross
    wrote on last edited by
    #1

    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 (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
    QMessageBox::warning(this, tr("File not found"), QString("%1\n%2").arg(tr("Can't find changelog file!")).arg(path));
    return;
    }@

    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 ?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      AcerExtensa
      wrote on last edited by
      #2

      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(")

      @QString(""%1%2%3%2%4"")@

      should be

      @QString("%1%2%3%2%4")@

      God is Real unless explicitly declared as Integer.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Anticross
        wrote on last edited by
        #3

        Thanks, AcerExtensa. Now it works.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved