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
Forum Updated to NodeBB v4.3 + New Features

Sorting directory entries with QDir

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.2k Views 2 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
    a8wz
    wrote on 21 Feb 2016, 22:41 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.

    K 1 Reply Last reply 22 Feb 2016, 05:40
    0
    • A a8wz
      21 Feb 2016, 22:41

      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.

      K Offline
      K Offline
      kshegunov
      Moderators
      wrote on 22 Feb 2016, 05:40 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

      1/2

      21 Feb 2016, 22:41

      • Login

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