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. opening file returns error 5 in qt
Qt 6.11 is out! See what's new in the release blog

opening file returns error 5 in qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.5k 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
    AndreAhmed
    wrote on last edited by
    #1

    0
    down vote
    favorite
    I'm trying to open a file for reading using qt and it doesn't open it, it returns an error 5. I don't know why ?

    loadObjModel("box.obj");
    QFile obj_file(path) ;

    QString errMsg;
    QFileDevice::FileError err = QFileDevice::NoError;
    if (!obj_file.open(QIODevice::ReadOnly)) {
        errMsg = obj_file.errorString();
        err = obj_file.error();
        qDebug() << QString(" err %1").arg(err) ;
    }
    if (!obj_file.open(QFile::ReadOnly))
    {
        qDebug() << QString("cannot open %1").arg(path) ;
        return ;
    }
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      The most likely is that your file is not a the path you are providing. For example, if your file is located in your sources and you wrote a relative path in your application code then it won't find it because they are not in the same folder. That's because by default Qt Creator uses Shadow Builds (which is a good thing).

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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