Help using QFile::open with a variable file path
-
Hey, I just can't seem to get QFile::open() working with a variable file path.
I'm trying to do :
@
QString filename;
Qfile file;ui->plainTextEdit->toPlainText() = filename;
file.open(filename, QIODevice::ReadWrite);
@But that isn't working. Anyone have any ideas? Thanks!
-
Oh, I see: the open() method of Qfile doesn't work the way you are thinking. You either need to pass the filename to the constructor, e.g.
@Qfile file (filename)@
or you need to set the name and then call open(), e.g.
@Qfile file;
file.setFileName (filename);
file.open(QIODevice::ReadWrite);@