Results 1 to 2 of 2

Thread: Cannot create file

  1. #1
    Join Date
    Apr 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Default Cannot create file

    Hello,
    I'm trying to output some text into a new file but the file.open call always returns false.
    Qt Code:
    1. QFile file("test.txt");
    2. if(file.open(QIODevice::ReadOnly | QIODevice::Text)){
    3. file.write(ui.label->toPlainText().toUtf8());
    4. file.close();
    5. }
    To copy to clipboard, switch view to plain text mode 

    I found the following in the documentation of QFile's open function:
    Note: In WriteOnly or ReadWrite mode, if the relevant file does not already exist, this function will try to create a new file before opening it.
    So I thought it may have something to do with the permissions, and I tried :
    Qt Code:
    1. file.setPermissions(QFile::WriteOwner);
    To copy to clipboard, switch view to plain text mode 
    But it returns false as well.

    Any idea about how I can create the file ?

    My environment :
    Qt 4.6.2
    Carbide.c++ 2.3.0
    S60 5th Edition SDK v1.0
    winscw emulator

  2. #2
    Join Date
    Apr 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Default Re: Cannot create file

    I found my mistake
    QIODevice::ReadOnly !

Similar Threads

  1. Create DLL file from Qt4
    By abghosh in forum Qt Programming
    Replies: 3
    Last Post: 3rd March 2010, 18:25
  2. Create a file
    By bfr in forum Qt Programming
    Replies: 2
    Last Post: 29th January 2008, 07:27
  3. How to create a access file .mdb
    By aiikcmo in forum Qt Programming
    Replies: 1
    Last Post: 22nd November 2007, 10:06
  4. how to create *.cpp file fm *.ui
    By Shuchi Agrawal in forum Qt Programming
    Replies: 2
    Last Post: 10th January 2007, 21:07
  5. create file in another directory
    By raphaelf in forum Qt Programming
    Replies: 3
    Last Post: 16th February 2006, 10:04

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.