QDir sorting in linux



  • 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]



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



  • 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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.