QString, how to delete new lines
Hi everybody,
i am reading some information by using QProcess::readAllStandardError() and it works fine.
I would like to delete all New lines of this String, but i dont know how to do this by using the Function QString::replace or remove :crying:
Can somebody help?
Now:
Code:
Connecting to STCHPS426...
Starting PsExec service on STCHPS426...
Connecting with PsExec service on STCHPS426...
Copying I:\WinZip 8.1.exe to STCHPS426...
Starting I:\WinZip 8.1.exe on STCHPS426...
WinZip 8.1.exe exited on STCHPS426
I want to have this:
Code:
Connecting to STCHPS426...
Starting PsExec service on STCHPS426...
Connecting with PsExec service on STCHPS426...
Copying I:\WinZip 8.1.exe to STCHPS426...
Starting I:\WinZip 8.1.exe on STCHPS426...
WinZip 8.1.exe exited on STCHPS426
Re: QString, how to delete new lines
Re: QString, how to delete new lines
Hi,
it dosent work :crying:
same result:
Code:
QString information
= process
->readAllStandardError
();
Re: QString, how to delete new lines
How often is readAllStandardError() called? It might be that it reads and gets "Connecting to STCHPS426..." then it is called several times but nothing is in StandardError, that's why you get newlines.
One of the possible solutions is to connect a readyReadStandardError() signal of QProcess to a slot, which will call readAllStandardError().
Re: QString, how to delete new lines
yes, im calling every 21 milisecond :)
Code:
QString information
= process
->readAllStandardError
();
QString defaulttext1
= "PsExec v1.94 - Execute processes remotely";
QString defaulttext2
= "Copyright (C) 2001-2008 Mark Russinovich";
QString defaulttext3
= "Sysinternals - www.sysinternals.com";
information.replace(defaulttext1, "");
information.replace(defaulttext2, "");
information.replace(defaulttext3, "");
information.replace("with error code 0.", "");
ui.information_te->setText(ui.information_te->toPlainText() + information);
I dont know how to delete these new lines :crying: :crying: :crying:
Re: QString, how to delete new lines
Ok, then try to do this.
1. get string from standardError
2. check, if it is not empty (with isEmpty()), then do ui.information_te->setText(ui.information_te->toPlainText() + information).
Re: QString, how to delete new lines
Why do you call it every 21 milisecond?
Would not it be better if you do
Code:
connect(yourProcess, SIGNAL(readyReadStandardError()), this, SLOT(readError()));
connect(yourProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(readOutput()));
...
void yourClass::readError()
{
// call readAllStandardError()
}
void yourClass::readOutput()
{
// call readAllStandardOutput()
}
Re: QString, how to delete new lines
Hi,
no, same result with new lines
Code:
if(!information.isEmpty())
{
ui.information_te->setText(ui.information_te->toPlainText() + information);
}
Re: QString, how to delete new lines
Try the way with signals and slots as in my previous post.