开发者

Best practice for using same source files in multiple projects in Qt Creator

开发者 https://www.devze.com 2023-03-12 03:14 出处:网络
I would like to use the same header and source file in multiple, closely related projects. Qt creator allows to have multiple projects open in the Projects bar, and it allows to \"Add existing files\"

I would like to use the same header and source file in multiple, closely related projects. Qt creator allows to have multiple projects open in the Projects bar, and it allows to "Add existing files". I can add source files from an other project to my current project, it appears nicely in the tree structure, but I can't #include them. The compiler just can't find them, even if they are included in the project. I even looked into the .pro file, and they appear there, with a relative path.

What is the best practice? If possible, I would like to avoid using any paths, even relative ones in the #includ开发者_StackOverflowe s in my source files, so the actual location of all the files would only be in the project file and nowhere else.


You can add include-file search paths in the .pro file like this:

INCLUDEPATH += ../MyIncludeFilePath0 F:/MyProj/MyIncludeFilePath1 etc.
0

精彩评论

暂无评论...
验证码 换一张
取 消