PDA

View Full Version : QDirModel and run a file depend of the filetype



TomASS
7th November 2009, 17:56
i'm showing a dir content by:


QDirModel *model = new QDirModel;
QTreeView *tree = new QTreeView();
tree->setModel(model);
tree->setRootIndex(model->index(QDir::currentPath()));
layout->addWidget(tree,0,0,1,1);

And the question is - how to "run" a file whith is clicked in application depend of the filetype (example like in windows)

squidge
7th November 2009, 22:50
bool QDesktopServices::openUrl ( const QUrl & url ) [static]

If the URL is a reference to a local file (i.e., the URL scheme is "file") then it will be opened with a suitable application instead of a Web browser.