Can not open file ( Qt )

This is a discussion on Can not open file ( Qt ) within the C++ Programming forums, part of the General Programming Boards category; Ok I have a file with constant name and want to open it. I am using Qt framework and I ...

  1. #1
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,675

    Can not open file ( Qt )

    Ok I have a file with constant name and want to open it.

    I am using Qt framework and I am on Mac.

    The path of my project is :
    ~Desktop/RayTracerFrameWorkOOP/
    (here I have everything, header, source files and all the relevant files of Qt)
    Here I have the file that I need to read from too. What I think is remarkable is that the file is of kind : Unix executable file

    From Qt IDE I open the project from the recent projects option with this path :
    ~Desktop/RayTracerFrameWorkOOP/QImageViewer.pro

    Here is the code
    Code:
      ifstream in("icosahedron_0.off");
        if (!in) {
            cout<<"\nError reading file."<<endl;
            exit(0);
        }
    and when I execute the program I am receiving the Error reading file message.

    Any ideas?
    Code - functions and small libraries I use


    It’s 2014 and I still use printf() for debugging.


    "Programs must be written for people to read, and only incidentally for machines to execute. " —Harold Abelson

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    The real question is, where is your executable (the result of the build process) and where is your data file? Unless they're in the same directory or the data file is in the directory QtCreator uses as the working directory when you launch, it won't find it.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,675
    Great point! I wasn't aware of that.
    When I execute I get this
    Code:
    /Users/usi/Downloads/QImageViewer-build-desktop-Qt_4_8_3__local__Release/QImageViewer.app/Contents/MacOS/QImageViewer exited with code 0
    And so I went to the file and put the file into it ( Also the folder models has the file which I am interested in )
    The image is taken in file QImageViewer-build-desktop-Qt_4_8_3__local__Release
    Name:  Screen Shot 2012-12-06 at 11.48.14 AM.jpg
Views: 122
Size:  39.6 KB
    Code - functions and small libraries I use


    It’s 2014 and I still use printf() for debugging.


    "Programs must be written for people to read, and only incidentally for machines to execute. " —Harold Abelson

  4. #4
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,675
    Well, we were instructed to put the absolute path, because nobody could open it.
    Code - functions and small libraries I use


    It’s 2014 and I still use printf() for debugging.


    "Programs must be written for people to read, and only incidentally for machines to execute. " —Harold Abelson

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Open file?
    By Therry in forum C++ Programming
    Replies: 6
    Last Post: 04-15-2012, 02:57 AM
  2. Cant open file
    By Pota in forum C++ Programming
    Replies: 3
    Last Post: 04-07-2011, 06:08 AM
  3. Replies: 3
    Last Post: 03-08-2010, 01:43 PM
  4. Open File/Save File crashes on cancel?
    By Blackroot in forum Windows Programming
    Replies: 0
    Last Post: 08-02-2008, 02:16 AM
  5. Replies: 12
    Last Post: 03-10-2005, 06:48 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21