Sort filenames naturally with Qt
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am reading a directories content using QDir::entryList() . The filenames within are structured like this: index_randomNumber . png I need them sorted by index , the way the Windows Explorer would sort the files so that I get 0_0815.png 1_4711.png 2_2063.png ... instead of what the sorting by QDir::Name gives me: 0_0815.png 10000 _6661 . png 10001 _7401 . png ... Is there a built-in way in Qt to achieve this and if not, what's the right place to implement it? 回答1: If you want to use QCollator to sort entries from the list of