argv);
QCoreApplication::setApplicationVersion(QT_VERSION_STR);
QCommandLineParser parser;
parser.setApplicationDescription("Qt Dir View Example");
parser.addHelpOption();
parser.addVersionOption();
QCommandLineOption dontUseCustomDirectoryIconsOption("c", "Set QFileIconProvider::DontUseCustomDirectoryIcons");
parser.addOption(dontUseCustomDirectoryIconsOption);
parser.addPositionalArgument("directory", "The directory to start in.");
parser.process(app);
const QString rootPath = parser.positionalArguments().isEmpty()
? QString() : parser.positionalArguments().first();
QLineEdit filterLineEdit;
filterLineEdit.show();
QFileSystemModel model;
model.setRootPath("");
model.setFilter(QDir::AllDirs | QDir::Files | QDir::Hidden);
if (parser.isSet(dontUseCustomDirectoryIconsOption))
model.iconProvider()->setOptions(QFileIconProvider::DontUseCustomDirectoryIcons);
QTreeView tree;
tree.setModel(&model);
tree.setRootIndex(model.setRootPath(QDir::currentPath()));
if (!rootPath.isEmpty()) {
const QModelIndex rootIndex = model.index(QDir::cleanPath(rootPath));
if (rootIndex.isValid())
tree.setRootIndex(rootIndex);
}
// Demonstrating look and feel features
tree.setAnimated(false);
tree.setIndentation(20);
tree.setSortingEnabled(true);
const QSize availableSize = QApplication::desktop()->availableGeometry(&tree).size();
tree.resize(availableSize / 2);
tree.setColumnWidth(0, tree.width() / 3);
tree.setWindowTitle(QObject::tr("Dir View"));
tree.show();
return app.exec();
}
а где у тебя обработка ввода чего-либо в filterLineEdit ?
Обсуждают сегодня