PDA

View Full Version : QFile BUG ? Problem with opening and writing



mlask
25th May 2012, 14:58
Hi

I have 3 classes:
- Main (QMainWindow)
- Settings (QDialog)
- Other (QDialog)

* This is working:
Starting my app, executing Settings window and change setting (radiobutton), then signal is emitted to Main and there QFile opens file and writes data.

* This is NOT working (file not written):
Starting my app, executing Other window, executing Settings window and change setting (radiobutton), then signal is emitted to Main window and there QFile opens and writes data.

Just open and close Other window cause that file can't be opened and written but:

file.isOpen()
returns true.

I tried write another file (other filename) but file wasn't created on disk.
However:
file2.isOpen()
returns true

In Main I have:
settings = new Settings(this);
other = new Other(this);

Sorry for my English :(

amleto
25th May 2012, 15:26
You are looking in the wrong location for your file. It exists.

mlask
25th May 2012, 16:03
I'm certain where file/files should be.

I almost fix the issue.
In "Other" I have a function which is called before opening Other window:

void Other::setpath(QString path)

There is a few lines, but when I COMMENT that one:
currentdir.setCurrent(Path); (currentdir is QDir)

then file IS WRITTEN.

Summary:
Setting path to QDir (path is proper and exists) in Other class, disables open/write file (QFile in Main class)

Any idea ?

------------------------EDIT---------------------------------------

Raplace:
currentdir.setCurrent(Path);

with:
currentdir.setPath(Path);

SOLVED the problem :confused:

This is very, very strange but real.

---

And you were right amleto :)
file and file2 was writing to dirpath...

I have no idea why.