0

I need to sort the contents of a QDir using the exif date (The time the picture was taken).

Now since most cameras name the photos sequentially I can achieve the sorting I want with myQDir.setSorting(QDir::Name), but if the camera resets it's count or I have images from two or more cameras in the same folder, I can't.

QDir::Time does not work either, because it's the time the picture was copied from the camera to the PC.

My program will run on windows and linux so I need a cross platform solution.

I've found easyexif from here but I don't know how to achieve what I want with it.

Any suggestions?

The Gramm
  • 118
  • 2
  • 12
  • Try with: `myQDir.setSorting(QDir::Time);` – eyllanesc Nov 27 '17 at 17:46
  • @eyllanesc I forgot to mention it in the question but I've already tried this. Check the updated answer. – The Gramm Nov 27 '17 at 18:47
  • so that you use QDir exactly, since I see that the ordering is in a private class and I find it difficult to overwrite that method. Maybe we can give another option. – eyllanesc Nov 27 '17 at 18:49
  • What other option? I use QDir because the application is in qt environment and I want it cross platform. – The Gramm Nov 27 '17 at 18:53
  • I do not mean that, maybe if I know the task you want to do, I might suggest another kind of Qt. – eyllanesc Nov 27 '17 at 18:55
  • [This](https://github.com/gramanas/rrwc/tree/multiThreadOutputs) is the project. I use the QDir in the `enginemanager.cpp` to get a list of all the images inside the folder. I want exif date sort so it will be usable in real life scenarios. – The Gramm Nov 27 '17 at 19:02
  • Do you want the paths stored in the variable `allFiles` to be sorted with that criterion? – eyllanesc Nov 27 '17 at 20:22
  • Yeah! That's the one! – The Gramm Nov 27 '17 at 20:23
  • Your code can be executed or still have problems? Every time I execute it, it generates a SIGARBT error, or indicates the procedure to use it. – eyllanesc Nov 27 '17 at 20:35
  • For me it works just fine :/ I am on linux tho – The Gramm Nov 27 '17 at 21:48
  • @TheGramm. I suppose you could use a `QFileSystemModel` with a `QSortFilterProxyModel` subclass that reimplements [lessThan](https://doc.qt.io/qt-5/qsortfilterproxymodel.html#lessThan). This would just need to return the result of comparing two exif `DateTimeOriginal` values (which could be converted to `QDateTime` first). – ekhumoro Nov 28 '17 at 01:12

0 Answers0