int main(int argc, char *argv[]) { QApplication app(argc, argv); QFileSystemModel model; QWidget window; QTreeView *tree = new QTreeView(&window); tree->setMaximumSize(1000, 600); QHBoxLayout *layout = new QHBoxLayout; layout->setSizeConstraint(QLayout::SetFixedSize); layout->addWidget(tree); window.setLayout(layout); model.setRootPath(""); tree->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents); tree->setModel(&model); tree->setAnimated(false); tree->setIndentation(20); tree->setSortingEnabled(true); tree->header()->setStretchLastSection(false); window.setWindowTitle(QObject::tr("Dir View")); tree->header()->setSectionResizeMode(QHeaderView::ResizeToContents); window.show(); return app.exec(); }
FileInspector::FileInspector(QString root, QWidget *parent) : QTableWidget(parent){ _model.setRootPath(root); QTreeView *tree = new QTreeView(this); tree->setModel(&_model); tree->setRootIndex(_model.index(_model.rootPath())); // look and feel tree->setAnimated(true); tree->setIndentation(10); tree->setSortingEnabled(true); tree->setFixedHeight(295); }
int main(int argc, char *argv[]) { QApplication app(argc, argv); QDirModel model; QTreeView tree; tree.setModel(&model); // Demonstrating look and feel features tree.setAnimated(false); tree.setIndentation(20); tree.setSortingEnabled(true); tree.setWindowTitle(QObject::tr("Dir View")); tree.resize(640, 480); tree.show(); return app.exec(); }