Results 1 to 3 of 3

Thread: problems when reading files (problems with .pro)

  1. #1
    Join Date
    Sep 2009
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Smile problems when reading files (problems with .pro)

    QFile file("D:\\Qt\\test\\out.txt");

    when i use the absolutePath, it works all right

    but when i use
    QFile file("./out.txt");
    i seems that i can't read the file

    out.txt and the code are in the same dir

    how to solve the problem with relative path

    THX

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: problems when reading files (problems with .pro)

    Well obviously your executable and your text file aren't in the same folder. See [WIKI]Current working directory[/WIKI] for a possible solution.

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

    lhdgriver (23rd July 2010)

  4. #3
    Join Date
    Sep 2009
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problems when reading files (problems with .pro)

    i've solved the problem myself. a totally newbie's problem, maybe

    edit the .qrc file and all problems are gone


Similar Threads

  1. Problems reading content of QFile
    By martinn in forum Newbie
    Replies: 12
    Last Post: 6th April 2010, 18:42
  2. Replies: 7
    Last Post: 11th December 2009, 05:01
  3. Problems reading XML with QDomDocument
    By grantbj74 in forum Qt Programming
    Replies: 9
    Last Post: 27th August 2009, 08:14
  4. Problems with loading ui files on windows
    By tyrdal in forum Qt Programming
    Replies: 2
    Last Post: 5th August 2009, 11:42
  5. header files problems
    By dognzhe in forum General Programming
    Replies: 1
    Last Post: 18th May 2009, 08:00

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.