Questions tagged [qfile]

A QFile is a class from the Qt Toolkit which provides an interface for reading from and writing to files.

QFile is an I/O device for reading and writing text and binary files and resources. A QFile may be used by itself or, more conveniently, with a QTextStream or QDataStream.

The official Qt documentation can be found here for Qt 4.8 and here for Qt 5.

305 questions
3
votes
1 answer

Qt QFile / QTemporaryFile cannot read or write

I have no idea why, but i can´t get the simplest example of QTemporaryFile to run... My real intent is to write data from QAudioInput into a temporary file before it is processed later. After trying several times I realized that neither .read(),…
Kevin
  • 43
  • 6
3
votes
2 answers

QT: Store QTextStream in QList

I'm trying to open multiple files simultaneously (random number of files) and store their textstreams in qlist for simple using in other code: QList files; QList
pixx
  • 125
  • 1
  • 8
3
votes
1 answer

QFile error : device not open

I have a code: int actualSize = 8; QFile tableFile("C:\\Users\\Ms\\Documents\\L3\\table"+QString::number(actualSize)+".txt"); QTextStream in(&tableFile); QString oneLine; oneLine.append(in.readAll()); if(tableFile.exists()) { …
Miklos
  • 101
  • 2
  • 11
3
votes
1 answer

Qt (C++): QFile creates text file successfully but does not write to it

I have the following code, with which I am attempting to write to a file. When it is called, the file is created in the directory and the for-loop is entered. The values for in QVector program also exist and are visible with qDebug(). However,…
Jordan
  • 97
  • 2
  • 11
3
votes
2 answers

Read File Using Relative Path on Linux Qt

Original one : QFile file("/home/casper/QuickRecorder/about_content.txt"); (Work) I have tried…
Casper
  • 4,435
  • 10
  • 41
  • 72
3
votes
1 answer

Renaming files with Qt

I'm trying to write a program that renames a certain list of files in a chosen directory with a new extension. Pretty much to replace all .dx90 files with .dx80 files. This is the code that I've written so far and it's not working. All the files are…
Nick Corin
  • 2,214
  • 5
  • 25
  • 46
3
votes
2 answers

Qt: Telling a program to read other files from the same directory as it's placed in

I have a program which is going to take a few different files as input. All I am going to know is that the files are going to be in the same folder as my program (and I know their names). Is there a way to write a path to a file knowing only its…
Silnik
  • 328
  • 2
  • 4
  • 14
3
votes
1 answer

os.walk analogue in PyQt

Before I can continue to implement recursive dir/file search with some filtering for some tasks I want to know if Qt/PyQt has analogue of os.walk. Main app is a GUI app in PyQt4 and all text fields in a QStrings and path objects (files, directories)…
Крайст
  • 776
  • 1
  • 9
  • 22
3
votes
2 answers

Qt create Link between folders

I have to build a small dialog that creates a symbolic link to a folder. In windows I would use mklink /D command. Is there a possibility to create such links in Qt? I have only seen QFile creating links between files and that they need to end with…
Richard
  • 1,543
  • 3
  • 25
  • 49
3
votes
1 answer

Why QDir::rmdir is not static?

QFile has a static function bool QFile::remove ( const QString & fileName ) [static] which deletes the specified file. This is handy: we have a path to file, and we use a command to remove it. However, QDir does not have such command, only this…
ScumCoder
  • 690
  • 1
  • 8
  • 20
3
votes
1 answer

QFile: how to efficiently read just bytes from k, to k+L

I can read bytes from k to k+L from QFile reading first whole file into QByteArray if (!file.open(QIODevice::ReadOnly)) //... QByteArray blob = file.readAll(); QByteArray bytes = blob.mid( k, L); How to read just bytes from k, to k+L,…
4pie0
  • 29,204
  • 9
  • 82
  • 118
3
votes
1 answer

Read a txt file into a QStringList

I have a file with 3000 strings (1 string-few words). I need to read the strings into a QList. How can I do that? I have tried the following: 1.txt string string2 function() <=> MyList<<"string"<<"string2";
punksta
  • 2,738
  • 3
  • 23
  • 41
3
votes
1 answer

Read from file with QDataStream: Is it faster with a buffer? How to do it?

I read binary data in portions (e.g. 100 bytes) from a file using QDataStream to process it then. Basically QDataStream stream(&file) with file being a QFile. Everything works fine so far. But I guess that in general processing is faster when small…
Chris
  • 981
  • 4
  • 14
  • 29
3
votes
3 answers

How to read an XML file from the disk using Qt?

I want to read an xml file as follow: QFile myFile("xmlfile"); and then continue with parsing the xml starting from : QXmlStreamReader xmlData(myFile); .. the error I get is: no matching function for call to…
McLan
  • 2,552
  • 9
  • 51
  • 85
3
votes
3 answers

The difference between QDataStream and QByteArray

QTemporaryFile tf; tf.open (); QDataStream tfbs (&tf); tfbs << "hello\r\n" << "world!\r\n"; const int pos = int (tf.pos ()); QByteArray ba; ba.append ("hello\r\n"); ba.append ("world!\r\n"); const int size = ba.size (); Basically my question is,…
cppguy
  • 3,611
  • 2
  • 21
  • 36
1 2
3
20 21