You do not pass the absolute file path to QFile::open() , and you do not check the result of opening the file. In your case, this is a failure, and open() returns false, but you ignore it, and do not fix the problem (wrong path) that caused it.
This is due to updating Qt 4 β Qt 5, and everything related to you suggests a misconception about the current directory that your application is facing. Generally speaking, the current directory (or working directory) is arbitrary, specific to the platform and circumstances, and is not completely controlled. If the user does not give you a file name that implicitly refers to the current working directory (for example, as the relative path specified by the command line argument), you must use absolute paths to the file or things just wonβt work.
source share