代码:
QDir dir(QDir::currentPath());//当前文件路径
QString filtername = "*.txt";
QStringList filter;
filter << filtername;
dir.setNameFilters(filter);
QStringList Neuronindex = dir.entryList();
ui.comboBox_3->addItems(Neuronindex);//把列表加载到comboBox_3
QString s = QString::number(Neuronindex.size());//txt文件个数
ui.lineEdit_2->setText(s);
效果: