Questions tagged [qtextstream]

The QTextStream class provides a convenient interface for reading and writing text.

QTextStream can operate on a QIODevice, a QByteArray or a QString. Using QTextStream's streaming operators, you can conveniently read and write words, lines and numbers. For generating text, QTextStream supports formatting options for field padding and alignment, and formatting of numbers.

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

90 questions
0
votes
2 answers

Qt Creator combobox

How to write Combobox current text in a preexisting text file in hard drive? Here is my code: void second::on_pushButton_4_clicked() { QFile file("vik.txt"); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) …
0
votes
1 answer

How to read a Google Doc as string of text?

I'm trying to make a little text analyzer using Google Apps script. I'd like to be able to read an entire Google Doc as a text string. I've tried using the editAsText() and getDataAsBlob() functions but neither seem to be returning the document…
0
votes
0 answers

segfault when reading QTextStream

Context: I have a set of file like that: alias USER = usr_name PASSWORD = pass ... alias2 ... I have a combobox to choose which file to display in a qtableview. The below is the slot called when the value of the combobox changes. void…
user2346536
  • 1,464
  • 2
  • 21
  • 43
0
votes
1 answer

Piping log output to QTextEdit widget

There are some 'similar' questions in stackoverflow, but can't quite implement them. In pyqt, I'm trying to pipe the output of a logfile (which is updating real-time) into a QTextEdit widget. The code I have so far is: file = QFile('tmp') …
Paul Nelson
  • 1,291
  • 4
  • 13
  • 20
0
votes
2 answers

Use QTextStream to read the first line in a string

How can I use QTextStream to read the first line in a string (read from a file before)? streamin = QTextStream(str) line = streamin.readLine() It seems that this code doesn't work.
WangTao
  • 3
  • 3
0
votes
1 answer

Parsing QTextStream

My problem is simple enough but I'm not able to fix this... In my header: QTextStream *in = NULL; in one method the QTextStream gets initialized: in = new QTextStream(&file); then I am trying to parse it in another method: QString next; if(in !=…
0
votes
1 answer

unable to read data form xml file using QTextStream

I tried to use QTextStream to read data from xml file,but at last I got empty string. Here is my code: QFile f("note.xml"); if(f.open(QIODevice::ReadWrite)){ QTextStream in(&f); in.setCodec("UTF-8"); qDebug()<
camperr
  • 9
  • 1
  • 4
0
votes
1 answer

QFile / QTextStream don't show error on delete file being written to

I am writing to a QFile using a QTextStream, and all works great. I'm trying to create some error detection, so I tried deleting the output file between writes. Strangle, Qtextstream's status continues to show 0 (no error), and QFile's error method…
TSG
  • 4,242
  • 9
  • 61
  • 121
0
votes
1 answer

Why will Qt not create a text file when running or debugging from inside Qt, but will create it when directly from the debug folder?

I am creating then writing to a text file using QTextStream. The problem is that the file is created if I build the application and run it from folder it creates, but if I run it from inside Qt in either release or debug mode it doesn't create the…
0
votes
2 answers

Qt - QTextStream - How to set cursor position to beginning of a line?

After readLine(), how to set cursor position to the beggining of a line? Using seek() and pos() doesnt work for me. Here is how my file.txt look like: Object1 Some-name 2 3.40 1.50 Object2 Some-name 2 3.40 1.50 3.25 Object3 Some-name 2 3.40…
user2224198
  • 13
  • 1
  • 5
-1
votes
2 answers

Infinite cycle due to QTextStream

So, I get infinite cycle while trying to read lines from file (line by line). I was trying to use do{}while(); cycle like that: QTextStream stream(stdin); QString line; do { line = stream.readLine(); } while (!line.isNull()); but I get empty…
bogdyname
  • 358
  • 2
  • 10
-1
votes
1 answer

Invalid Operands to Binary Conversion for QTextStream

I need to know about the conversion for QTextStream to a bool variable. Have a look at my code : QFile file(SOME FILENAME); if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) qDebug() << "FILE COULD NOT BE OPENED"; QTextStream…
Satish Joshi
  • 71
  • 1
  • 7
-1
votes
1 answer

I can't save .txt file with QFileDialog, C++ QT

This is my code: void MainWindow::save(){ QString fileName = QFileDialog::getSaveFileName(this, tr("Save Text File"), path, tr("Text Files (*.txt)")); if (fileName != "") { QFileInfo info(fileName); path =…
KFGC
  • 1
  • 4
-1
votes
1 answer

Setting the name of a text file to a variable in qt

I'm exporting data to a text file in qt every time a run a code. With my current code that file is overwritten each time. My question is how can I set the title to be a variable eg pulse_freq, this way new files will be created based on my variable…
Duanne
  • 137
  • 1
  • 3
  • 13
-1
votes
1 answer

Qt reading textfile with QTextStream

I've got trouble reading a text file with Qt. My text file looks like this: 17,9001500000000 31,1151700000000 450 0 NaN NaN NaN NaN NaN NaN 1 1 1390309311,00000 0,999847695156391 0,999847695156391 0,999847695156391 …
smaica
  • 723
  • 2
  • 11
  • 26
1 2 3 4 5
6