我正在尝试检查目录是否为空。
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!!!");
}
}
检查它的正确方法是什么,不包括
.
和 ..
?
最佳答案
好吧,我有办法做到这一点:)
if(QDir("/home/highlander/Desktop/dir").entryInfoList(QDir::NoDotAndDotDot|QDir::AllEntries).count() == 0)
{
QMessageBox::information(this,"Directory is empty","Empty!!!");
}
关于qt - 检查目录是否为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16351699/