c++ - Cannot open file in resources directory -


i've tested every natural iteration can imagine right still can not open file qfile object. i've tested placing file in ./resources directory , in directory source file.

i've cleaned project in between each test , restarted qt creator well. i've deleted *.pro.user project configuration file , tested new versions of that.

#include <qfile> #include <qdebug> ... //qfile input_file("./resources/testfile.txt"); //qfile input_file("qrc:/10_graph.txt"); //qfile input_file("testfile.txt"); qfile input_file(":/testfile.txt"); if (!input_file.exists()) {   qdebug() << "file not exist";   exit(11); } 

enter image description here

qt creator >> about

qt creator 3.1.1 (opensource) based on qt 5.2.1 (clang 5.0 (apple), 64 bit)

you should add resource file project , add testfile.txt resources. after can access file resources :

qfile input_file(":/testfile.txt"); 

if add prefix resources can accessed :

qfile file(":/someprefix/new.txt"); 

if put file in folder alongside source directory , add resources, can access :

qfile file(":/foldername/new.txt"); 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -