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::entryInfoList() not returning files with accents in Qt 5.10+

QDir::entryInfoList() not returning files with accents in Qt 5.10+

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 561 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.
  • I Offline
    I Offline
    Inviska
    wrote on last edited by Inviska
    #1

    A Mac user of my rename software reported that files with accents in the name weren't showing up in the file list after I changed Qt version. Investigating the issue, I started to think it was a problem with QDir in Qt 5.10+.

    I produced a simple program to display the output of QDir::entryInfoList() in a QTextEdit. I sent him versions of this program built with Qt 5.9.0 and Qt 5.12.2. He tested the two builds with a directory containing ten files, half of which had accents in the name. When he runs the Qt 5.9.0 build all ten files show up:

    alt text

    However, only six files are returned by QDir::entryInfoList() when he runs the Qt 5.12.2 build, and four of the files containing accents are missing:

    alt text

    This issue only happens on the user's computer. When I test on the Mac with the same ten files they all show up in all versions of Qt, as you can see in this screenshot. I wondered if it was an issue related to locale, so I changed my Region and Language to French, but I still couldn't recreate the problem.

    The project for the test program can be downloaded here and the builds I used for testing are here. I'll paste the code for the test project below as well.

    main.cpp

    #include <QApplication>
    #include "Dialog.h"
    
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
        Dialog dialog;
        return app.exec();
    }
    

    Dialog.h

    #ifndef DIALOG_H
    #define DIALOG_H
    
    #include <QDialog>
    #include <QTextEdit>
    
    class Dialog : public QDialog
    {
        Q_OBJECT
    private:
        QTextEdit* dirContents;
    
    public:
        Dialog();
    
    private slots:
        void OpenDir();
    
    private:
        void ReadDir(QString path);
    };
    
    #endif // DIALOG_H
    

    Dialog.cpp

    #include <QtWidgets>
    #include "Dialog.h"
    
    
    Dialog::Dialog()
    {
        dirContents = new QTextEdit(this);
        QPushButton* openDir = new QPushButton(tr("Open Directory"), this);
        QVBoxLayout* layout = new QVBoxLayout(this);
        layout->addWidget(dirContents);
        layout->addWidget(openDir);
        setLayout(layout);
    
        dirContents->setReadOnly(true);
        setWindowTitle(QString("Qt %1").arg(QT_VERSION_STR));
        connect(openDir, SIGNAL(clicked()), this, SLOT(OpenDir()));
        show();
    }
    
    
    void Dialog::OpenDir()
    {
        QFileDialog fileDlg(this);
        fileDlg.setFileMode(QFileDialog::Directory);
        fileDlg.setOptions(QFileDialog::ShowDirsOnly);
        fileDlg.setWindowTitle(tr("Open Directory"));
        fileDlg.setDirectory(QDir::homePath());
        if (fileDlg.exec())
            ReadDir(fileDlg.selectedFiles().at(0));
    }
    
    
    void Dialog::ReadDir(QString path)
    {
        QDir dir(path);
        dir.setFilter(QDir::AllEntries | QDir::NoDotAndDotDot);
        dir.setSorting(QDir::Name | QDir::DirsFirst | QDir::LocaleAware);
        QFileInfoList fileList = dir.entryInfoList();
    
        dirContents->clear();
        dirContents->append(QString("%1\nNum Files: %2\n").arg(QDir::toNativeSeparators(path)).arg(fileList.size()));
    
        QFileInfoList::const_iterator file;
        for (file = fileList.constBegin() ; file != fileList.constEnd() ; ++file)
            dirContents->append(file->fileName());
    }
    
    

    Can anyone suggest why files aren't showing up on the user's computer with Qt 5.10+? Is it something I'm doing wrong or is it likely a Qt problem?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Does you user have that issue on all its disks or is it happening on for example a network drive ?
      What filesystem is he using ?
      Did he modify anything in his Windows machine settings ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • I Offline
        I Offline
        Inviska
        wrote on last edited by
        #3

        He's working with files in his User directory on his main disk.

        I'm not sure about his file system. It'll be either HFS+ or APFS but I'd have to check which.

        He may have changed some settings, but it's hard to imagine any setting would result in a situation where Qt 5.9.0 builds works while Qt 5.10+ builds omit files.

        He originally reported the problem over a year ago when he was using macOS 10.13 and he's still experiencing the same issue on 10.14. Programs built with Qt 5.9 work fine, but with Qt 5.10+ files with accents don't show up on his machine.

        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