Results 1 to 3 of 3

Thread: Launch app by opening a file

  1. #1
    Join Date
    Dec 2008
    Location
    Paris, France
    Posts
    34
    Thanks
    3
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Launch app by opening a file

    This beginner's question must surely have been asked and aswered already, however the search through this forum gives nothing.

    I have created the links to associate a given file extension to my app. Having done that, is there a method to process the parameters in main(int argc, char *arg[]) to get the file name ?

    The *char array apparently is the app path concatenated with the file path, but is it possible to get the file path only ?

    Thanks in advanced for any help

    andre

  2. #2
    Join Date
    Dec 2008
    Location
    Paris, France
    Posts
    34
    Thanks
    3
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Launch app by opening a file

    I finally figured it out

    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QString PathName, Extension;
    4. PathName=argv[1];
    5.  
    6. Extension = PathName.right(4);
    7. if(Extension.compare(".ext",Qt::CaseInsensitive)==0)
    8. {
    9. LoadFile(PathName);
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to Windsoarer for this useful post:

    sparticus_37 (5th March 2011)

  4. #3
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Launch app by opening a file

    You could also have used QFileInfo::suffix

Similar Threads

  1. Replies: 9
    Last Post: 23rd August 2012, 00:01
  2. Replies: 1
    Last Post: 13th May 2009, 03:18
  3. Problem in opening a file
    By Abc in forum Qt Programming
    Replies: 2
    Last Post: 12th August 2008, 12:40
  4. Re: Opening Project file Issue in Edyuk
    By philwinder in forum Qt-based Software
    Replies: 6
    Last Post: 5th May 2008, 20:49
  5. Opening swf file in the default browser
    By munna in forum Qt Programming
    Replies: 16
    Last Post: 5th May 2006, 09:33

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.