我正在尝试检查目录是否为空。
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!!!");
}
}
正确的检查方法是什么,排除.
and ..
?
好吧,我有办法做到这一点:)
if(QDir("/home/highlander/Desktop/dir").entryInfoList(QDir::NoDotAndDotDot|QDir::AllEntries).count() == 0)
{
QMessageBox::information(this,"Directory is empty","Empty!!!");
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)