Results 1 to 2 of 2

Thread: QDirModel and run a file depend of the filetype

  1. #1
    Join Date
    Apr 2009
    Posts
    75
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default QDirModel and run a file depend of the filetype

    i'm showing a dir content by:

    Qt Code:
    1. QDirModel *model = new QDirModel;
    2. QTreeView *tree = new QTreeView();
    3. tree->setModel(model);
    4. tree->setRootIndex(model->index(QDir::currentPath()));
    5. layout->addWidget(tree,0,0,1,1);
    To copy to clipboard, switch view to plain text mode 

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

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDirModel and run a file depend of the filetype

    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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.