c++ - File Input - File not being read QT -



c++ - File Input - File not being read QT -

i'm new c++ , qt. basically, done java stuff, we're beingness thrown in c++ module, in have design zork game ui. way planning create room object have room constructed roomnum.long, .short , .name long desc, short desc , name.

for first room, i'm going load file straight moment until onto objects etc properly. however, can't seem file written text label. homecoming "restart game etc" written on button press, not contents of file. rooms folder in same folder source file (islandmain.cpp in case)

any ideas?

void theislandmain::on_startbutton_clicked() { ui->roomdesc->settext(readfirstroom("/rooms/room1.long")); ui->roomdesc->setwordwrap(true); } qstring theislandmain::readfirstroom(qstring filename) { qfile mfile(filename); if (!mfile.open(qfile::readonly | qfile::text)) { qdebug() << "could not open file reading line 31"; homecoming "could not load file. please restart game."; } qtextstream in(&mfile); qstring fileinput = in.readall(); qdebug() << fileinput; mfile.close(); homecoming fileinput; }

check if file exists using bool qfile::exists(const qstring& path) , if filename have in function or whole path (path needed)

soo long zai

c++ file qt input

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -