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. Open external file with parameter

Open external file with parameter

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 6.5k 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.
  • P Offline
    P Offline
    prsolucoes
    wrote on last edited by
    #1

    Hi,

    How to execute a binary/executable file with Qt ?

    To open a normal file, we can use:

    @QUrl url = QUrl::fromLocalFile("file:///Users/paulo/Pessoal/downloads/cpp/poco-doc/110-Logging.pdf");
    QDesktopServices::openUrl(url);@

    But i cant pass any parameter, because i get "file not found".

    Can anyone help me?

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lgeyer
      wrote on last edited by
      #2

      [quote author="prsolucoes" date="1315889693"]How to execute a binary/executable file with Qt?[/quote]
      "QProcess":http://doc.qt.nokia.com/latest/qprocess.html is what you are looking for.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goetz
        wrote on last edited by
        #3

        QDesktopServices::openUrl() cannot take any parameters. This is logical, as that method does not know which application is used to open the file, that depends on the users preferences. For example, you might want to use a super fast preview program or gimp or photoshop to open an image. Each of that programs does have its own set of command line options (if any!), so it does not make sense to pass those.

        The only alternative is to utilize [[Doc:QProcess]], as Lukas suggested. But be aware that you must know which program to use for the file (e.g. Acrobat Reader or some open source application, maybe the Preview.app on the Mac) and probably the path too.

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0
        • P Offline
          P Offline
          prsolucoes
          wrote on last edited by
          #4

          Hi,

          Thanks. This is the solution.

          Ty.

          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