diff --git a/examples/widgets/itemviews/dirview/main.cpp b/examples/widgets/itemviews/dirview/main.cpp
index bc1b8a5d7b6d7bccf4320b3de893a2eb8d98e3d0..abca413325559873e36f578b9037e9e33021ad10 100644
--- a/examples/widgets/itemviews/dirview/main.cpp
+++ b/examples/widgets/itemviews/dirview/main.cpp
@@ -39,25 +39,45 @@
 ****************************************************************************/
 
 #include <QApplication>
+#include <QDesktopWidget>
 #include <QFileSystemModel>
 #include <QTreeView>
+#include <QCommandLineParser>
+#include <QCommandLineOption>
 
 int main(int argc, char *argv[])
 {
     QApplication app(argc, argv);
 
+    QCoreApplication::setApplicationVersion(QT_VERSION_STR);
+    QCommandLineParser parser;
+    parser.setApplicationDescription("Qt Dir View Example");
+    parser.addHelpOption();
+    parser.addVersionOption();
+    parser.addPositionalArgument("directory", "The directory to start in.");
+    parser.process(app);
+    const QString rootPath = parser.positionalArguments().isEmpty()
+        ? QString() : parser.positionalArguments().first();
+
     QFileSystemModel model;
     model.setRootPath("");
     QTreeView tree;
     tree.setModel(&model);
+    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.resize(640, 480);
     tree.show();
 
     return app.exec();