hi, I would like to get information from TextEdit in Qt line by line and write it in vector. How it is possible to do thanks. Would like to get vectorarr = {"{9,1,6,6}","{0,4,3,11}","{3,22,8,33}","{11,3,8,3}"};
Get data from QTextEdit line by line in QT
11.9k Views Asked by AudioBubble At
2
There are 2 best solutions below
0

QString QTextStream::readLine(qint64 maxlen = 0)
For reading text you can use QTextStream
QString text = ui->lineEdit->text();
QTextStream * stream = new QTextStream(&text , QIODevice::ReadOnly);
QString line1 = stream->readLine();
QString line2 = stream->readLine();
qDebug() <<line1;
For adding it into vector
QString text = ui->lineEdit->text();
QTextStream * stream = new QTextStream(&text , QIODevice::ReadOnly);
QVector<QString > lines;
while (!stream->atEnd())
{
lines << stream->readLine();
}
You can get All QTextEdit text and split it by
\n
(new line).Get QTextEdit text:
Split it to by
\n
(new line):Screenshot: