Check if directory is empty
问题 I'm trying to check if a directory is empty. MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QDir Dir("/home/highlander/Desktop/dir"); if(Dir.count() == 0) { QMessageBox::information(this,"Directory is empty","Empty!!!"); } } Whats the right way to check it, excluding . and .. ? 回答1: Well, I got the way to do it :) if(QDir("/home/highlander/Desktop/dir").entryInfoList(QDir::NoDotAndDotDot|QDir::AllEntries).count() == 0) { QMessageBox: