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 Issues With QTextStream

QFile vfile(file); if(!vfile.open(QIODevice::ReadWrite | QIODevice::Text)) qDebug() << "FILE COULDN NOT BE OPENED"; QTextStream stream(&vfile); stream << "Hello" << "="; vfile.write("132"); Output to File - 132Hello= In the above example, I write…
Satish Joshi
  • 71
  • 1
  • 7
0
votes
1 answer

Repeatedly write and read to/from QBuffer via QTextStream

I am trying to repeatedly write and read to/from a QBuffer object via QTextStream. First I construct both objects: QBuffer b; b.open(QIODevice::ReadWrite); QTextStream s(&b); // Setup text stream here Then I write three different portions of…
Silicomancer
  • 8,604
  • 10
  • 63
  • 130
0
votes
1 answer

C++ write to resource file with qfile (QIODevice::write (QFile,"x"): device not open)

i have the following problem, i have an resource file called data.txt and i want to open it with write permission. Im using QFile and QTextStream to work with it. I can only open the File with ReadOnly Acces but not with ReadWrite or WriteOnly…
Max
  • 62
  • 1
  • 7
0
votes
0 answers

QT second file not being added to ByteArray

I am trying to merge 2 files,they contain hex data presented like…
Aaron Manill
  • 41
  • 1
  • 7
0
votes
0 answers

adding lines to a file when push button pressed

i want write a string to a text file when i press the button but no matter how much i press the button the string gets written on the first line on the text file so how can i do it? My code inside the buttons function is this: QFile…
Faeyan
  • 1
0
votes
1 answer

QTextStream is unable to write to file including "\t" with openmode QIODevice::Append

I tried to save some info to the text file using QTextStream. The code is given below: QFile fi(QString("result.txt")); fi.remove(); if(!fi.open(QIODevice::Append)) { qDebug()<<"Cannot open file!"; return -1; } QTextStream ts(&fi); float…
user957121
  • 2,946
  • 4
  • 24
  • 36
0
votes
1 answer

QTextStream and QFile pointer

I have a class which is absfilehandler which has a QFILE pointer like this.. QString absfilename; QFile * absfilepointer; I have a opening method. bool AbsFileHandler::OpenAbsFile() { QFile readfile(absfilename); absfilepointer =…
0
votes
1 answer

How to create an ISO 8859-15 (instead of default UTF-8) encoded text file on Linux using QTextStream?

The function below is something I have created in a unit test for a Qt project I'm working on. It creates a file (empty or filled) that is then opened in various use cases, processed and the outcome evaluated. One special use case I have identified…
rbaleksandar
  • 8,713
  • 7
  • 76
  • 161
0
votes
0 answers

Q: Display console output in a widget using Pyside with QTextStream

INTRODUCTION I am an absolute beginner in Python and I am writing a program that reads the output of a scale and shows it in real-time in a widget. I am using QTextStream with PySide and Python 2.7.14. PROBLEM DESCRIPTION The basic program listens…
parovelb
  • 353
  • 4
  • 19
0
votes
1 answer

How do I write QList Stored items using qt's QTextStream?

That is how i tried it at first but i get an error "no operator found that takes a left hand operand of type 'QTextStream' or there is no acceptable conversion" QListlNamesList; void write(){ QFile…
Zero Cool
  • 1
  • 1
0
votes
0 answers

QTextStream: Add Prefix and Suffix to the beginning/end of a stream segment

I have a simple container class holding a QTextStream. I use it to write to a file. What I want is that the function below adds at the beginning of a stream operator call "LogHandle() << "foo" << 1234;" a prefix. E.g. "LOG:" and at the end a new…
dgrat
  • 2,214
  • 4
  • 24
  • 46
0
votes
1 answer

How to use QTextStream with PythonQT?

I am writing a plugin for a Qt desktop app using PythonQT. I wonder how to use << operator in python. QTextStream stream(&file); stream << doc.toString(); Any hints? How may I ask Python to list all methods for a given class like QTextStream? Or is…
Olaf Japp
  • 480
  • 5
  • 19
0
votes
2 answers

Qt : Read a text file line by line in a specific time interval

I am trying to transfer the content of a text file to be displayed to the textEdit widget inside my GUI. How can I make it display at the text edit one line at a time, instead of displaying all the content of the text file into the textEdit widget…
0
votes
1 answer

How to make a text file with Qt

I am making a GUI application in which the user insert some information and click either an Add button to add more info, or a Finished button to finish the process. The outputs of the process are going to be 4 text files. So, I've made a class with…
0
votes
1 answer

Subscribe more outputs to QTextStream

I was just following this topic "How to print to console when using Qt" in order to make my application work. I started to wonder- Is it possible to subscribe more outputs to a single QTextStream? For example, lets say when I wrote something to my…
Łukasz Przeniosło
  • 2,725
  • 5
  • 38
  • 74