Results 1 to 3 of 3

Thread: QFile BUG ? Problem with opening and writing

  1. #1
    Join Date
    May 2012
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QFile BUG ? Problem with opening and writing

    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

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QFile BUG ? Problem with opening and writing

    You are looking in the wrong location for your file. It exists.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. #3
    Join Date
    May 2012
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QFile BUG ? Problem with opening and writing

    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

    This is very, very strange but real.

    ---

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

    I have no idea why.
    Last edited by mlask; 25th May 2012 at 15:28.

Similar Threads

  1. Replies: 2
    Last Post: 9th August 2011, 08:37
  2. Problem in opening postscript image
    By deck99 in forum Qt Programming
    Replies: 1
    Last Post: 19th March 2011, 10:09
  3. Problem in opening a file
    By Abc in forum Qt Programming
    Replies: 2
    Last Post: 12th August 2008, 12:40
  4. QFile resized files gets truncated after writing
    By MaximA in forum Qt Programming
    Replies: 1
    Last Post: 24th May 2008, 17:23
  5. problem in writing text with QFile
    By wei243 in forum Qt Programming
    Replies: 5
    Last Post: 6th March 2007, 14:26

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.