Results 1 to 5 of 5

Thread: How i Get Path From Command Line Argument

  1. #1
    Join Date
    Oct 2011
    Posts
    36
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default How i Get Path From Command Line Argument

    How i Get Path From Command Line Argument

    I Tested

    Qt Code:
    1. QStringList arg=QCoreApplication::arguments();
    To copy to clipboard, switch view to plain text mode 

    But it,s Problem With Space on Path
    Example : D:\My Files
    this Splited to 2 Arguments
    1=D:\My
    2=Files

    how i do this with out Example Problem

    Thanks

  2. #2
    Join Date
    May 2011
    Posts
    239
    Thanks
    4
    Thanked 35 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Symbian S60

    Default Re: How i Get Path From Command Line Argument

    If you give your app a command line D:\My Files , why should Qt think it is one string? Obviously it is two for Qt.

    Luckily it is simple: just add quotation marks around it: "D:\My Files"

  3. #3
    Join Date
    Oct 2011
    Posts
    36
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How i Get Path From Command Line Argument

    I added quotation marks around it it
    but i send multi string to my program
    Example: D:\My Files*D:\
    i want split When * the problem is splited when Space

  4. #4
    Join Date
    Oct 2007
    Location
    Lake Forest, CA, USA
    Posts
    132
    Thanks
    10
    Thanked 27 Times in 22 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: How i Get Path From Command Line Argument

    Join all arguments in one QString and then use QString::split(). Using space as separator is OS related stuff, Qt simply provide easy access to it.
    Oleg Shparber

  5. #5
    Join Date
    Oct 2011
    Posts
    36
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How i Get Path From Command Line Argument

    Thanks Very Much Oleg

Similar Threads

  1. QString argument ignoring new line characters
    By qtnewbi3 in forum Qt Programming
    Replies: 4
    Last Post: 15th August 2011, 22:18
  2. How to compile from command line?
    By tonnot in forum Newbie
    Replies: 6
    Last Post: 15th March 2011, 14:55
  3. QProcess and the command line
    By auba in forum Qt Programming
    Replies: 17
    Last Post: 27th May 2009, 10:39
  4. Printing to Command Line
    By seanmu13 in forum Qt Programming
    Replies: 3
    Last Post: 5th July 2007, 15:57
  5. Is there a command-line window in Qt4?
    By miaoliang in forum Qt Programming
    Replies: 2
    Last Post: 8th November 2006, 08:56

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.