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

QDir sorting in linux

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

    Hi All,

    I have some files like this:
    -rw-r--r-- 1 zamek zamek 130609 Apr 15 18:25 2014.04.15_18:24:44.org
    -rw-r--r-- 1 zamek zamek 32643 Apr 16 11:21 2014.04.16_11:21:15.org
    -rw-r--r-- 1 zamek zamek 32643 Apr 16 11:28 2014.04.16_11:28:03.org
    -rw-r--r-- 1 zamek zamek 1040 May 11 09:21 t_2014.05.11_09:21:20.org
    -rw-r--r-- 1 zamek zamek 1040 May 16 22:57 t_2014.05.16_22:57:45.org

    I would like to get a list of reverse order by time:

    @
    QDir dir(root);
    QStringList filter("*.org");
    dir.setNameFilters(filter);
    dir.setFilter(QDir::Files | QDir::NoSymLinks);
    dir.setSorting(QDir::Time : QDir::Reversed);
    QFileInfoList list = dir.entryInfoList();
    @

    and I got it in ascending order.
    Did I do a mistake?

    I use qt 5.2 on debian Linux.

    thx
    Zamek

    [edit: added missing coding tags @ SGaist]

    1 Reply Last reply
    0
    • C Offline
      C Offline
      clochydd
      wrote on last edited by
      #2

      Hi, you should use "|" instead of ":" here:
      @
      dir.setSorting(QDir::Time | QDir::Reversed)
      @

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        zamek
        wrote on last edited by
        #3

        Hi,

        Oh sorry, it was |.
        Original code is:
        @
        dir.setSorting(orderAsc==0 ? QDir::Time : QDir::Reversed | QDir::Time);
        @
        I removed it from the post.

        thx
        Zamek

        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