Solution to the problem of vs2017 error report unable to open source file

Problem Description:

Problem Description: a new QT GUI project is created without any modification, but the error list shows that the existing file cannot be opened, and there are various red underscores under the header file of the file code, but it can be run directly main.cpp no problem.

terms of settlement:

For the existing files in the project that cannot be opened, it means that the path of the current project is not included. Here, you can refer to the acquisition method of C + + header file reference (c + + knowledge focus). So we just need to add in the current project path.
Methods: right click the project, click properties, select the included directory in VC + + directory, add $(projectdir) , then apply and confirm.

principle

#Include & lt; XX. H & gt; means to search for files directly from the function library of the compiler, and the compiler starts to search for. Xxh from the standard library path

#Include “XX. H” means to search from the user-defined file first. If not, search from the function library. The compiler starts to search XX. H from the user’s working path

If we refer to the header file written by ourselves in the way of & lt; & gt;, we will inevitably be unable to find the source file, because our file is placed in the user directory. The above solution is essentially to append the user directory to the compiler search scope. In fact, we can solve the problem by replacing & lt; & gt; with “” instead.

Read More: