Opening a file using operating system default program for the file type



  • Hi,

    I have a number of file names attached to an entry in a database. I simply want the user to be able to open the file in the default program.

    Something like this:
    @QFancyClass()->openFileUsingDefaultMimeHandler(myfilename).@

    I've had a look at QProcess, QFile and QDir, but I'm still not sure how to do this. I've most likely missed something; I'd appreciate any pointers!

    Thanks in advance.

    Edit: I have no need to communicate with the spawned process or anything, I just want to launch it.


  • Moderators

    Use QDesktopServices:
    @
    QDesktopServices::openUrl(QUrl::fromUserInput("path/to/the/file"));
    @



  • Excellent, thank you very much!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.