#include <QApplication>
#include <QFileSystemModel>
#include <QTreeView>
#include <QDebug>
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QFileSystemModel model;
model.setRootPath(QDir::currentPath());
QTreeView treeview;
treeview.setModel(&model);
treeview.setRootIndex(model.index(QDir::currentPath()));
treeview.show();
QObject::connect(&treeview, &QTreeView::pressed, [&](const QModelIndex &
index) {
qDebug() << model.fileName(index);
});
return app.exec();
}
简单的一段代码,lamda表达式的&换成=,通过传值的方式为啥无法访问model?传递引用则可以捕获这个外部变量?
--
FROM 101.20.43.*