demo-image-viewer-qt

demo-image-viewer

It’s a demonstration only image viewer made with Qt6. The binaries are available.

Screenshot


Features


Here is the example of the console log, after the program is started (~70 ms):

The speed results for 350 KB image with a directory with 30000+ files (Run it with Qt Creator to look at the qDebug() logs):

At this moment the image is visible.

That is performed in a background thread:


Note: Do NOT use code that calls methods of QFileInfo in std::sort. It’s incredibly slow.

That is up to 600 times slower

        std::sort(fileEntryList.begin(), fileEntryList.end(),
                  [](const FileEntry& a, const FileEntry& b) {
                      return a.fileInfo.lastModified() < b.fileInfo.lastModified();
                  }
        );

than that

        std::sort(fileEntryList.begin(), fileEntryList.end(),
                  [](const FileEntry& a, const FileEntry& b) {
                      return a.mtime < b.mtime;
                  }
        );

3200-3600 ms vs 6 ms.

So, store all required fields of QFileInfo in your own data struct.

Try by yourself (uncomment the line 307 and comment lines 298-304): https://github.com/AlttiRi/demo-image-viewer/blob/ad9ac9b1c9d78244462064983e676542700e96d9/core.h#L296-L311