Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Open File with QFile

Open File with QFile

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 401 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ODБOïO Offline
    ODБOïO Offline
    ODБOï
    wrote on last edited by ODБOï
    #1

    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( !jsonFile.open(QFile::ReadOnly)){
            qDebug()<< "file not found";
           }
    ...
    
    }
    

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

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bonnie
      wrote on last edited by Bonnie
      #2

      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.

      ODБOïO 1 Reply Last reply
      3
      • B Bonnie

        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.

        ODБOïO Offline
        ODБOïO Offline
        ODБOï
        wrote on last edited by
        #3

        @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 ..!
               backend.loadOperationsListFromFile(file)
               stack.push("OperationEditor.qml")
           }
        

        thx!

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved