Qmake 获取父目录

様 貴*_*の微笑 4 qt qmake

我尝试获取 PWD 的父目录。我尝试../$$PWD。这是行不通的。最初的任务是获取父子目录的地址,但到目前为止我什至无法降级目录。

TEMPLATE = app
Parent_path = $$PWD //here i get smt like C:/Myproject/project(here is my project.pro), but i need only C:/Myproject
Run Code Online (Sandbox Code Playgroud)

Fly*_*ole 5

将您的代码更改为

Parent_path = $$PWD/../
Run Code Online (Sandbox Code Playgroud)

或者

Parent_path = $$clean_path($$PWD/../)
# Where `../` is resolved.
Run Code Online (Sandbox Code Playgroud)

因为..是到父目录的硬链接。然后你可以使用你的Parent_path变量像这样

message($$Parent_path)
Run Code Online (Sandbox Code Playgroud)