Important: Please read the Qt Code of Conduct -

Open File with QFile

  • Hi,

    I am using QFile class to load a file
    it looks like my file is correctly loaded but i have this 3 lines in application output

    QFSFileEngine::open: No file name specified
    file not found
    QIODevice::read (QFile, ""): device not open

    this is my code

     static QList<Operation *> loadJob(QString name){
            QFile jsonFile(name);
           if( !{
            qDebug()<< "file not found";

    Can someone tell me why i have this "fake" errors please ?

  • From your log, the open operation is failed, with an empty "name".
    So this is not "fake".
    If you are sure the file is loaded, maybe the code was executed twice, once success, once failed.
    You can set a breakpoint and debug.

  • @Bonnie hi
    Yes you are right thank you very much for the fast answer!

    it was called 2 times because of this

    onSelectedFileChanged: {
           var file = selectedFile 
           selectedFile = "" // this makes  the 2nd call  because SelectedFileChanged is triggered again ..!


Log in to reply