c++ - Cannot capture the file already opened error in qt 5 -


i have function initial file check , returns false in case there error in opening file.

filehandler::filehandler(qstring str)   //getting filename :qfile(str){}  bool filehandler::initialfilecheck() {     if(!filehandler->open(qiodevice::writeonly))     {         globalvar::errormessage = filehandler->errorstring();         return false;     }      return true; } 

filehandler->errorstring() gives "unknown error" on console (application output) can see error displayed -- qfile::open: file (/home/test.txt) open

how can capture error , put in errormessage?

i know can use filehandler->error() error enumerator , map string enumerator of useless creation of map.

any comment or suggestion welcomed


Comments