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
1 answer

Writing to QTextStream

My QTextStream is empty when this code finishes: QString line1 = "This is line one"; QString line2 = "This is line two"; QString line3 = "This is line three"; QString outputFilename = "temp.txt"; QFile…
Alan
  • 1,265
  • 4
  • 22
  • 44
0
votes
1 answer

Access violation error when using QTextStream to read from console

I have problem, got access violation when trying to use QTextStream for data reading or writing to console: First-chance exception at 0x77BD1D76 (ntdll.dll) in ApplicationStub.exe: 0xC0000005: Access violation writing location 0x00000014. Unhandled…
user7031116
0
votes
0 answers

Making ncurses work with Qt qtextstream

I'm currently trying to make a Qt console program work with ncurses. I would like to enjoy the advantages of ncurses while still being able to use QTextStream for input and output. The idea is to use while((c = getch())..... for one particular type…
user129186
  • 1,156
  • 2
  • 14
  • 30
0
votes
1 answer

Qt, QTextStream - inputting a char/string into an int

Consider the following program: int num; QTextStream(stdin) >> num; QTextStream(stdout) << num; Like this, if I am to incorrectly input a string, or a char, into the variable num, its value becomes 0 by default. How can I change the behavior of…
user129186
  • 1,156
  • 2
  • 14
  • 30
0
votes
2 answers

Ownership of QString with QTextStream

I am trying to use QTextStream to read from a QString. Since the constructor has the following signature: QTextStream(QString *string, QIODevice::OpenMode openMode = QIODevice::ReadWrite) (see the documentation) Since the constructor is passed…
giorgio-b
  • 113
  • 7
0
votes
1 answer

seek line in qtextStream

im using QTextStreamer to read a QFile using if(file.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream stream(&file); line = stream.readLine(); //... but in my requirement i need only to read particular set of lines only from…
Wagmare
  • 1,354
  • 1
  • 24
  • 58
0
votes
1 answer

How to read new lines from a file as another process is appending them?

So I have ffmpeg writing its progress to a text file, and I need to read the new values (lines) from the said file. How should I approach this using Qt classes in order to minimize the amount of code I have to write? I don't even have an idea where…
Violet Giraffe
  • 32,368
  • 48
  • 194
  • 335
0
votes
1 answer

How do you do a Yes/No dialogue using Qt on the commandline?

I know a poor way of doing it: QTextStream cin(stdin); QString choice = cin.readLine(); if (choice == "yes" || choice == "y") {... I'd like though to do it where when it shows up in cmdline: Accept quest? (y/n) y Where: y is displayed by…
Anon
  • 2,267
  • 3
  • 34
  • 51
0
votes
1 answer

Qt QTextStream to QList item

I would like to fill QList directly using QTextStream. I have this code working right: QList str; QFile file_read1("C:/Programs/file.txt"); if(file_read1.open(QFile::ReadOnly)) { QTextStream read1(&file_read1); read1.seek(0); int…
Tomas_cz
  • 83
  • 13
0
votes
1 answer

QTextStream::readAll returns empty QString

I was trying to loop through all children of specific XML node and join their name attributes. The structure: The desired result: PARAM1='$PARAM1',PARAM2='$PARAM2',PARAM3='$PARAM3'[...] The code: //…
Tomáš Zato
  • 50,171
  • 52
  • 268
  • 778
0
votes
1 answer

How can I read character by character from a text file in QT C++?

I want to read from a text file like simple C++'s fgetc but with QT QTextStream where I tried readall method but it skip the last characther which probably is a break.
user3540983
  • 141
  • 1
  • 4
  • 11
0
votes
1 answer

QT reading file line by line

I need to read the contents of a file line by line. Sample.txt: #define temp 10 Code: QFile file("D:\Sample.txt"); QTextStream in(&file); QString str_Line = in.readLine(); str_Line contains #definetemp10 How to read the line…
IPS
  • 81
  • 1
  • 12
0
votes
1 answer

Qt read specific columns of tab delimited text file

I'm working on a program that reads a text file of tab delimited doubles and sums up each column, effectively calculating the integral of each column. What I want to be able to do is choose a specific column to sum up rather than sum all the…
Mitchell D
  • 465
  • 8
  • 24
0
votes
1 answer

QTextStream writes wrong data to file

I try to read and write from same file but get strange behavior. Here is example code : mainwindow.h #ifndef MAINWINDOW_H #define MAINWINDOW_H #include #include #include namespace Ui { class…
ratojakuf
  • 708
  • 1
  • 11
  • 21
0
votes
0 answers

Cant read text file and save it in stl vector with QFile

this is my first question here, i always found the answers i need but today, that "always" has ended haha. My problem is that i'm trying to read a text file with QFile and QTextStream and save the values inside an STL vector. When i try to read the…