Results 1 to 2 of 2

Thread: Processing on the File

  1. #1
    Join Date
    Mar 2011
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Processing on the File

    Hi
    I want to open the file that is in a place in my computer . I use this code but it doesn't open it . How can I open that file ?

    Qt Code:
    1. QString path = "C:\Program Files (x86)\vnb.txt" ;
    2. QFile inFile( path );
    3. if (!inFile.open(QIODevice::ReadOnly | QIODevice::Text))
    4. return -1 ;
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Processing on the File

    That is most likely because your path is not good, remember that you are still using C++ and \ is an escape character, so you need to double it in a string, try it like this:
    Qt Code:
    1. QString path = "C:\\Program Files (x86)\\vnb.txt" ;
    To copy to clipboard, switch view to plain text mode 
    Doesn't your compiler warn about unknown escape characters?

Similar Threads

  1. File Processing Application Quirk
    By sgrant327 in forum Qt Programming
    Replies: 1
    Last Post: 9th September 2010, 18:55
  2. image processing
    By IRON_MAN in forum Qt Programming
    Replies: 4
    Last Post: 18th November 2009, 13:37
  3. warning while processing ui file
    By dreamer in forum Qt Programming
    Replies: 1
    Last Post: 5th July 2008, 19:33
  4. Image Processing using Qt
    By danielperaza in forum Qt Programming
    Replies: 2
    Last Post: 9th March 2008, 18:15
  5. XML processing instruction
    By mattia in forum Newbie
    Replies: 1
    Last Post: 26th February 2008, 11:37

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.