Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Opening a file using operating system default program for the file type

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

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Apelsinsaft
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

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

      (Z(:^

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Apelsinsaft
        wrote on last edited by
        #3

        Excellent, thank you very much!

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved