Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QIODevice::write: device not open” when file is open

QIODevice::write: device not open” when file is open

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 8.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jeronimo
    wrote on last edited by Jeronimo
    #1

    hi if i am using some file and it's openned. I can't write there? This error can crash my program? or it's only one alert?

    Ni.SumiN 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      How did you open the file ? Are you sure that you are not writing to a ReadOnly file ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • J Jeronimo

        hi if i am using some file and it's openned. I can't write there? This error can crash my program? or it's only one alert?

        Ni.SumiN Offline
        Ni.SumiN Offline
        Ni.Sumi
        wrote on last edited by Ni.Sumi
        #3

        @Jeronimo

        This error can crash my program? or it's only one alert?

        If you are not writing any thing, it can not be crash. It is better to post the your exact error . So that , its easy to say the specific solution.

        Better to post some of your code to find the error. Here is the sample code that you can read and write to the file. It can be done in many ways, this is some sample rough code.

        Void MainWindow :: someFucntionName() {
             QString path = qApp->applicationDirPath(); //location of the file, assuming in application dir
        	path.append("./yourTextFile.txt");
        	QFile fileUrl(path);
        	if( fileUrl.open(QIODevice::ReadWrite | QIODevice::Text) ) {      
                QTextStream out(&fileUrl);
                out<< "something" << endl;
            }
        
        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved