Questions tagged [qiodevice]

The QIODevice class is the base interface class of all I/O devices in Qt.

The QIODevice class is the base interface class of all I/O devices in Qt.

QIODevice provides both a common implementation and an abstract interface for devices that support reading and writing of blocks of data, such as QFile, QBuffer and QTcpSocket. QIODevice is abstract and can not be instantiated, but it is common to use the interface it defines to provide device-independent I/O features. For example, Qt's XML classes operate on a QIODevice pointer, allowing them to be used with various devices (such as files and buffers).

Before accessing the device, open() must be called to set the correct OpenMode (such as ReadOnly or ReadWrite). You can then write to the device with write() or putChar(), and read by calling either read(), readLine(), or readAll(). Call close() when you are done with the device.

QIODevice distinguishes between two types of devices: random-access devices and sequential devices.

  • Random-access devices support seeking to arbitrary positions using seek(). The current position in the file is available by calling pos(). QFile and QBuffer are examples of random-access devices.
  • Sequential devices don't support seeking to arbitrary positions. The data must be read in one pass. The functions pos() and size() don't work for sequential devices. QTcpSocket and QProcess are examples of sequential devices.

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

60 questions
0
votes
2 answers

Write a new text without losing the previous value.in Qt

How can i Write a new text without losing the previous value QString mFilename2 = "bin/bin_2.txt"; File_main_Editor.stWrite(mFilename2,okline_Edit); void stWrite(QString Filename,QString stringtext){ QFile…
Qasim
  • 83
  • 10
0
votes
0 answers

How to correctly use QSerialPort to write and read data constantly?

I have to pilot a Laser at work, to do that I need to communicate with a serial port in RS232. As you must be cautious when you use a laser, you need to constantly read the laser status (temperature, power, etc...) and to do that you have to send a…
ElevenJune
  • 423
  • 1
  • 4
  • 21
0
votes
2 answers

QAudioOutput - application size is continuously growing

I'm trying to write into buffer for QAudioOutput every 20ms. When I try to execute this code I can see the size of process increases about 4-8 kB per second. I was trying to find some function to clear internal buffer of QIODevice or DAudioOuptut…
Filip
  • 3
  • 2
0
votes
0 answers

How to prevent QNetworkAccessManager from buffering POST contents from QIODevice?

I am not sure if the functionality I need isn't something that Qt is just not capable of but it seems that since there are multiple valid use cases maybe I am doing something wrong and someone has already dealt with this. What I want do to is pretty…
Rudolfs Bundulis
  • 11,636
  • 6
  • 33
  • 71
0
votes
0 answers

readyRead() signal in qextserialport is not being emitted

I am using qextserialport to communicate with a Bluetooth device on a Windows 8.1. I defined a ComPort class. I need to first write a message {0xA9,0x55} on "COM5" to ask the Bluetooth device start transmitting data. Then I can start reading data. I…
QuestionMark
  • 412
  • 1
  • 4
  • 16
0
votes
1 answer

Qt 4.8 Why my QIODevice not output a text in this code?

If used QTextStream console(stdout) - all work just fine, but if I wrote custom IODevice, after qInstallMsgHandler() no text in console main.cpp #include "remoteconsole.h" #include #include #include…
Andrey Reeshkov
  • 331
  • 5
  • 14
0
votes
1 answer

How to write a raw QByteArray or manipulate the QByteArray

I defined a QIODevice (especially a QTcpSocket) and would like to write a string as raw format. I describe my wishes with the following example: char* string= "Hello World"; QByteArray bArray; QDataStream stream(&bArray,…
3ef9g
  • 781
  • 2
  • 9
  • 19
0
votes
2 answers

How to change POST data in qtwebkit?

For change POST variables in qtwebkit need change or replace outgoingData in createRequest(...). How to create own not QFile or QByteArray. Exactly QIODevice object! It is needed for creation of writable…
0
votes
1 answer

Qt QTcpSocket streaming

My application sent object to the server via QTcpSocket. Client: void client::sendFile(QString path) { QFile toSend(path); QByteArray rawFile; rawFile = toSend.readAll(); QDataStream out(cl); out >> rawFile; } Server: void…
WildDev
  • 2,250
  • 5
  • 35
  • 67
0
votes
1 answer

QIODevice::readAll() not working properly?

I am currently working on a project that involves serial communication between a Arduino and a laptop. I know the Arduino is indeed sending the data that I need, see this picture: http://s1.postimg.org/w5wisaetr/Help.png Now on the other end my…
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
3 answers

Trouble in reading from Serial port using QSerialPort

I have to develop a C++ program for an embedded FriendlyARM-based processor system. I use Qt Creator 3.0.0 (based on Qt 5.2.0) for desktop computer. My program should be able to read from serial port at Mini2440 FriendlyARM processor. Before going…
0
votes
0 answers

QIODevice Write at End

I have the following setup, audio_output = new QAudioOutput(*audio_format, this); audio_device = audio_output->start(); // Return QIODevice audio_device->open(QIODevice::ReadWrite); I need a function that writes data to the end of the audio_device…
Jacob
  • 1,335
  • 1
  • 14
  • 28
0
votes
1 answer

Difference between QSocketNotifier::activated and QIODevice::readyRead

I create a new Read QSocketNotifier (QSocketNotifier::Read) and I install it on a QSslSocket. What is the QSslSocket signal that is emitted when activated signal is emitted from QSocketNotifier? Is there any difference between the activated signal…
Jacob Krieg
  • 2,834
  • 15
  • 68
  • 140
-1
votes
2 answers

QIODevice::ReadWrite | QIODevice::Unbuffered - Unsupported open mode

http://doc.qt.io/qt-5/qserialport.html#open Warning: The mode has to be QIODevice::ReadOnly, QIODevice::WriteOnly, or QIODevice::ReadWrite. Other modes are unsupported. Following code does not open the serial port. if(serialPort.open…
Aquarius_Girl
  • 21,790
  • 65
  • 230
  • 411
1 2 3
4