Results 1 to 4 of 4

Thread: Resolving external executables path in platform independent way

  1. #1
    Join Date
    Jul 2009
    Location
    Oulu, Finland
    Posts
    23
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question Resolving external executables path in platform independent way

    Hey,

    I have to implement application that can launch external applications. I thought of using QProcess for launching the external apps and it works just fine.

    Now I would like to know if there is any platform independent way of finding or resolving these external application's executable paths? Let's say that I would like to find path to the MyExtApp.exe or the equivalent (MyExtApp) in unix systems. Is there anything specific in Qt that can help me with this? Or any other generic solution for my problem?

    Any suggestions are welcome.

    -Tepi

  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: Resolving external executables path in platform independent way

    If the app is in the system path, then just run the app without an absolute directory prefix.

    Otherwise you will have to search for it, depending on the application. Some applications registered with the system (eg. web and email) can be run using the URL handler.

  3. #3
    Join Date
    Jul 2009
    Location
    Oulu, Finland
    Posts
    23
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Resolving external executables path in platform independent way

    Thanks for your reply fatjuicymole

    but this doesn't quite clear the problem of how to find where the executables are located. Let's say that we cannot assume anything about the location of the executable, we just know the name of the programs executable (MyExtApp) and we have to check if there's executable with that name on the machine. If not we should get the info about that too.

    So how to do the search?

    I know that this might sound like an exaggeration since usually installed apps are located in certain locations (or at least their executables). But when I can check the whole machine then it's quite easy to narrow down the locations afterwards... I think

    And remember, this should all be done in platform independent manner... if it's even possible

  4. #4
    Join Date
    Jul 2009
    Location
    Oulu, Finland
    Posts
    23
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Resolving external executables path in platform independent way

    Hi again,

    now I have tested some different methods of launching external applications and files. I have used QProcess and QDesktopServices for launching. They seem to do their job as expected in Windows but with Linux QDesktopServices doesn't want to launch external applications directly. Although it opens files, for example pdf files, as expected in default PDF reader program.

    Now is there a way to get QDesktopServices to launch application executables also in Linux. Or should i just use QProcess to launch executables, as it works fine.

    Here's code that does it's job as expected:
    Qt Code:
    1. QString program = "/path/to/executable";
    2. QStringList arguments;
    3.  
    4. QProcess *process = new QProcess(this);
    5. process->start(program, arguments);
    To copy to clipboard, switch view to plain text mode 

    The following code does the job in Windows but does nothing in Linux:
    Qt Code:
    1. QDesktopService::openUrl(QUrl("path/to/executable"));
    To copy to clipboard, switch view to plain text mode 

    So is there a way to get QDesktopServices working or should I just use QProcess to start those executables and stick with QDesktopServices with other kind of files and resources? I would really like to use just QDesktopServices to do the job because it's so simple way to launch different type of files with their default programs...

    Edit: I looked the application output and it says "No application is registered as handling this file", so it seems that Linux is expecting some other application to launch these, even if the file is executable itself. Which seems quite strange... I have to take closer look at that then
    Last edited by Tepi; 18th January 2010 at 11:55.

Similar Threads

  1. Q3ScrollView resists to scroll down to the garbage bin
    By sivrisinek in forum Qt Programming
    Replies: 0
    Last Post: 5th February 2009, 17:50
  2. Replies: 16
    Last Post: 23rd May 2008, 10:12
  3. Crash handler on Win32
    By niko in forum Qt Programming
    Replies: 3
    Last Post: 12th November 2007, 19:41

Tags for this Thread

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.