Results 1 to 15 of 15

Thread: file.open error

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2011
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: file.open error

    the iterator doesnt mater, the filename doesnt seem to matter.. and as far as the error try looking at this line again....
    Qt Code:
    1. QFile file(filename);
    2. if (!file.open(QIODevice::ReadOnly))
    3. {
    4. QMessageBox::information(this, tr("Unable to open file"), file.errorString());
    5. return;
    6. }
    To copy to clipboard, switch view to plain text mode 

    when the app starts it calls load() to grab the list file for the filename and location. This file loads fine and I have no problems with it, its not until I try to load the other files to back them up that the problem shows up. The vector holds the filename and location. it->fullpath is the full filepath and filename, this can be swapped out for the actual path and not from the vector and it gives the same result... The vector is fine.. there is nothing wrong with the vector or iterator so those should be ignored.

    If you reread the code you will see the file.errorstring.. that is where the message comes from. While reading the code look at ALL the QMessagebox statements. Each time something gets started a messagebox should pop up and tell me whats about to happen. In the code posted in this thread the if has a return, so the remaining code should be ignored. The entire function was posted to see how it is supposed to work.


    Added after 5 minutes:


    Quote Originally Posted by SixDegrees View Post
    I have no idea what 'it' is, but assuming it's an iterator I'll note that it is never changed between these two statements, so you are potentially attempting to read and write to the same file. Maybe it->fullPath() and it->getFile() are sufficiently different for this to work, but it certainly isn't clear without knowing more about what 'it' points to.
    Yes it is the same file. fullpath is the location of the original while getfile only used the filename itself so the file gets saved in the applications directory. Currently I am using C:\test as the file locationd and C:\test2 as the application directory. So the app will load file xxx.whatever from C:\test and save it to C:\test2 Eventually I will compress the files and save all of them in something like xxx.bak but for now I need the initial file.open to work...
    Last edited by pheonixstorm; 2nd July 2011 at 20:53.

  2. #2
    Join Date
    Apr 2010
    Posts
    769
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11
    Thanks
    1
    Thanked 94 Times in 86 Posts

    Default Re: file.open error

    Then your problem lies elsewhere than in the code you've fixated on. Run your program in a debugger.

  3. #3
    Join Date
    Jan 2011
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: file.open error

    Nothing to be found in the debugger either.

  4. #4
    Join Date
    Jan 2011
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: file.open error

    No ideas why file.open would fail to open a file? Has no one encountered a problem like this before?

Similar Threads

  1. fatal error LNK1104: cannot open file 'libgles_cm.lib
    By danmaliki in forum Installation and Deployment
    Replies: 2
    Last Post: 24th March 2011, 13:17
  2. Replies: 3
    Last Post: 1st November 2010, 16:33
  3. Replies: 0
    Last Post: 3rd June 2010, 04:54
  4. Replies: 4
    Last Post: 9th May 2010, 16:18
  5. Qt 4.1.4 on VS2005 error- cannot open input file 'qtmain.lib'
    By Ashish in forum Installation and Deployment
    Replies: 10
    Last Post: 11th October 2006, 16:05

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
  •  
Qt is a trademark of The Qt Company.