Reputation: 811
I have a QTextBrowser
in which I display the output contents of an external binary using QProcess
in Linux. All is GOOD! But most of the contents are just boxes, so now it's the character encoding UTF-8 is missing and I need to tell this to the QTextBrowser
. Is there any way for that?
The code:
....
processRAM = new QProcess();
processRAM->start("memtester", QStringList() << "1" << "1");
.....
connect(processRAM, SIGNAL(readyRead()),this,SLOT(displayRAMTestOutput()));
......
void MainWindow::displayRAMTestOutput()
{
textBrowserData->append(Qtring::fromUtf8(processRAM->readAllStandardOutput())));
}
I added the char encoding UTF-8 and still I see only boxes. What am I missing here?
Upvotes: 2
Views: 1558
Reputation: 1965
You can set content of QTextBrowser
in this way:
textBrowser->setText(QString::fromUtf8(processOutput)));
EDIT:
Your problem with "boxes" isn't connected with UTF8 encoding. Symbols which you see are control characters which are used by memtester when it displays text to console. If you don't want to display such characters in textBrowser
, you can filter output:
while(!processRAM->atEnd())
{
QString out = QString::fromAscii(processRAM->readLine());
if(!out.contains("\b"))
textBrowser->append(out);}
}
\b
means backspace which is displayed in you textBrowser as boxes.
Upvotes: 3