在我的执行文件夹内建了xml/monitor子文件夹 ,并判断 QString monitro_name;是否存在。
我使用if (!QFile::exists(":/xml/monitor/"+monitor_name)), 但还是无法判断,困恼好久了,
------解决方案--------------------
":/xml/monitor/"+monitor_name ---- :开头是从资源文件里找,不是可执行文件夹下。
换成"./xml/monitor/"+monitor_name 试试
------解决方案--------------------
Xml/monitor
------解决方案--------------------
你把"./xml/monitor/"+monitor_name 赋给一个QString对象,然后看看路径是否正确,因为在调试的时候,“./”所指的路径是项目文件所在的路径,并非exe文件的路径。
------解决方案--------------------
弄成绝对路径不就没问题了。
------解决方案--------------------
看我的截图吧,相对路径肯定没问题,是相对于编译后生成的.exe所在的目录



------解决方案--------------------
看看以下几个路径就清楚了:
QDir::currentPath()
QCoreApplication::applicationFilePath()