Results 1 to 3 of 3

Thread: QIODevice::open: File access not specified

  1. #1
    Join Date
    Apr 2015
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default QIODevice::open: File access not specified

    Hi.

    I am trying to open a file with the following code:

    Qt Code:
    1. QFile* file = new QFile(filename);
    2. QDataStream* stream;
    3.  
    4. if (file->open(QIODevice::ReadOnly))
    5. {
    6. stream = new QDataStream(file);
    7. }
    8. else
    9. {
    10. PRINT("Error opening file");
    11. return;
    12. }
    To copy to clipboard, switch view to plain text mode 

    And the program outputs:
    Qt Code:
    1. QIODevice::open: File access not specified
    To copy to clipboard, switch view to plain text mode 
    . I would assume that the file access is ReadOnly. What am I doing wrong.
    I am using Qt 5.2.1 and Qt Creator 3.0.1.
    Last edited by Clausen; 19th April 2015 at 14:46.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QIODevice::open: File access not specified

    Which line prints this warning?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Apr 2015
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: QIODevice::open: File access not specified

    That is a very good point.
    It seems that it was a brainfart on my part.

    The message is from somewhere else in the code where I use

    Qt Code:
    1. file.open(QIODevice::Text);
    To copy to clipboard, switch view to plain text mode 

    if I change this to

    Qt Code:
    1. file.open(QIODevice::Text|QIODevice::Append);
    To copy to clipboard, switch view to plain text mode 

    Then the warning disappears.

    So I guess all I needed was the very good question.
    Thank you for your help. :-)

Similar Threads

  1. Questions about QAudioOutput, QIODevice. Play wav file
    By Smosia in forum Qt Programming
    Replies: 3
    Last Post: 19th March 2014, 13:15
  2. Replies: 2
    Last Post: 18th October 2013, 18:16
  3. Replies: 1
    Last Post: 7th May 2013, 00:34
  4. Replies: 4
    Last Post: 9th May 2010, 16:18
  5. QFile Problem~ "Unknow error" in "open(QIODevice::ReadWrite)"
    By fengtian.we in forum Qt Programming
    Replies: 3
    Last Post: 23rd May 2007, 15:58

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.