Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qfile and Qresource problem



  • I am working with a few dictionaries and as I am cross-compiling it would be usefull if I would use the resource folder instead.

    I was already using the Resource folder for a .jpg file but it is not working when I want to open my textfile.

    QPixmap logo(":/resources/img/logo.jpg"); // works
    
    QFile file(":/resources/img/Dictionary2.csv.txt"); // does not work
    
    user@user:~/Dropbox/GUI/GUI_Qt/img$ ls
    Dictionary2.csv.txt  logo.jpg  toolbox1.png  toolbox2.png // the file is present in the folder
    

    What am I not knowing? ...besides alot :P



    • Did you add Dictionary2.csv.txt to the qrc file?
    • Can you try QFile file(QFileInfo(":/resources/img/Dictionary2.csv.txt").absoluteFilePath());?


  • @VRonin said in Qfile and Qresource problem:

    • Did you add Dictionary2.csv.txt to the qrc file?

    Nope, did so now, thank you.


Log in to reply