Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Open external file with parameter

    General and Desktop
    3
    4
    6093
    Loading More Posts
    • 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
      prsolucoes last edited by

      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 Reply Quote 0
      • L
        lgeyer last edited by

        [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 Reply Quote 0
        • G
          goetz last edited by

          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 Reply Quote 0
          • P
            prsolucoes last edited by

            Hi,

            Thanks. This is the solution.

            Ty.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post