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. Sorting directory entries with QDir

Sorting directory entries with QDir

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.1k Views
  • 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.
  • a8wzA Offline
    a8wzA Offline
    a8wz
    wrote on last edited by a8wz
    #1

    I am building a QFileInfoList from a directory and I want the list sorted by "Date created".
    QDir::Time uses the "Modified Date" and as far as I am aware there is no way to sort by "Date Created" using QDir. I can certainly use QFileInfo::created() and sort the list in code, but according to Qt documentation this will only work on Windows systems, apparently Linux returns "Modified Date" in most instances even when QFileInfo::created() is used. My application is multi-platform and I need to find a solution that works on both platforms. Any suggestions of how to handle this situation is most appreciated.

    kshegunovK 1 Reply Last reply
    0
    • a8wzA a8wz

      I am building a QFileInfoList from a directory and I want the list sorted by "Date created".
      QDir::Time uses the "Modified Date" and as far as I am aware there is no way to sort by "Date Created" using QDir. I can certainly use QFileInfo::created() and sort the list in code, but according to Qt documentation this will only work on Windows systems, apparently Linux returns "Modified Date" in most instances even when QFileInfo::created() is used. My application is multi-platform and I need to find a solution that works on both platforms. Any suggestions of how to handle this situation is most appreciated.

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by kshegunov
      #2

      @a8wz
      Hello,
      This is because (ordinarily) Linux doesn't keep a separate date for the creation of a file. There's no "date created" on most file systems that run on Linux, so naturally Qt, because it uses the available OS API, is unable to ascertain what is the creation time. You don't have much leeway but to use the modified time as a reference.
      Here you can read a bit more on the subject.

      Kind regards.

      Read and abide by the 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