文章如果有显示异常,绝对是CSDN的锅…
居然不能显示“$$”,所以只能用“$$”代替(或者是我没找到方法,希望看到的朋友能给个提示)…
1. pro/pri中加入带空格的路径:$$quote
例:INCLUDEPATH += $$quote(C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include)
2.pro/pri文件中定义函数,分为两种,一种是不带返回值的,另一种是返回BOOL类型的。
例:
//The purpose is data processing, return result
defineTest(func1){
variable = $$1
!build_pass:message(test_func $$variable)
return (true)
}
//Returns a function of bool
defineReplace(func1){
message($$1 $$1) #get the first arg
message($$ARGS $$ARGS) #get all args
for(v, 1){
!build_pass:message($$v)
}
//Print the value of args
for(v, ARGS){
!build_pass:message($$v)
}
return ($$1)
}
//define two variables
NAME = lance
AGE = 24
func1($$NAME, $$AGE):!build_pass:message(success)
ABC = $$func1($$NAME, $$AGE)
!build_pass:message($$ABC)
输出:
Project MESSAGE: test_func lance
Project MESSAGE: succ