Using conditions when customize qt project

混江龙づ霸主 提交于 2019-12-05 10:29:29

The values stored in the CONFIG variable are treated specially by qmake. Each of the possible values can be used as the condition for a scope. So, your project file can be wrote simply as:

CONFIG += APP1

APP1 {
  LIBS += <LIB1>
  DESTDIR = <DIR1>
} else {
  LIBS += <LIB2>
  DESTDIR = <DIR2>
}

I just want to note 1 thing about the conditions Make sure the curly bracket is not the same line. Otherwise it will fail

Good

CONFIG += opencv_32_bit

opencv_32_bit {

} else {

}

Will fail

CONFIG += opencv_32_bit

opencv_32_bit 
{

}
else
{

}

I'm not sure why, but I had this problem since I prefer braces on the next line

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!