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 and qrc files = bad file descriptor
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] QFile and qrc files = bad file descriptor

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 1.4k 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.
  • M Offline
    M Offline
    MaxL
    wrote on last edited by
    #1

    Hi everyone,

    I have an issue with QFile when opening a file found in my qrc file.
    What i'd like to do is to have a file descriptor on a file located in a qrc file.

    I successfully open in ReadOnly mode my file but when i ask for the handle I always get -1, is there anyway to get the file descriptor ? or it is simply impossible ?

    Thanks :)

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tucnak
      wrote on last edited by
      #2

      @
      QFile file("foo.bar");
      file.open(QIODevice::ReadOnly);
      int fileHandle = file.handle();

      FILE* f = fdopen(fileHandle, "r");
      @

      Are you sure that code above is not working for your setup?

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        @_tucnak_, It's not the same setup

        A file retrieved from Qt's resources is not the same a file from your own filesystem.

        However, there's a workaround for that, you can use QTemporaryFile. Open a temporary file, write the content of your resource in it and then use it for whatever you need.

        Hope it helps

        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