Results 1 to 9 of 9

Thread: QString, how to delete new lines

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default 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().
    Last edited by lyuts; 25th June 2008 at 11:11.
    I'm a rebel in the S.D.G.

  2. #2
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: QString, how to delete new lines

    yes, im calling every 21 milisecond

    Qt Code:
    1. QString information = process->readAllStandardError();
    2. QString defaulttext1 = "PsExec v1.94 - Execute processes remotely";
    3. QString defaulttext2 = "Copyright (C) 2001-2008 Mark Russinovich";
    4. QString defaulttext3 = "Sysinternals - www.sysinternals.com";
    5. information.replace(defaulttext1, "");
    6. information.replace(defaulttext2, "");
    7. information.replace(defaulttext3, "");
    8. information.replace("with error code 0.", "");
    9. information.replace(QString("\n\n\n\n\n"), QString("\n"));
    10. ui.information_te->setText(ui.information_te->toPlainText() + information);
    To copy to clipboard, switch view to plain text mode 

    I dont know how to delete these new lines
    Think DigitalGasoline

  3. #3
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default 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).
    I'm a rebel in the S.D.G.

  4. #4
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QString, how to delete new lines

    Why do you call it every 21 milisecond?

    Would not it be better if you do
    Qt Code:
    1. connect(yourProcess, SIGNAL(readyReadStandardError()), this, SLOT(readError()));
    2. connect(yourProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(readOutput()));
    3. ...
    4.  
    5. void yourClass::readError()
    6. {
    7. // call readAllStandardError()
    8. }
    9.  
    10. void yourClass::readOutput()
    11. {
    12. // call readAllStandardOutput()
    13. }
    To copy to clipboard, switch view to plain text mode 
    I'm a rebel in the S.D.G.

Similar Threads

  1. char* to QString. Segfault after delete []
    By TheRonin in forum Qt Programming
    Replies: 9
    Last Post: 19th June 2008, 13:20
  2. easiest Way QString can do
    By baray98 in forum Qt Programming
    Replies: 12
    Last Post: 15th April 2008, 20:49
  3. Convert from iso-8859-1 to... Something else :-)
    By Nyphel in forum Qt Programming
    Replies: 4
    Last Post: 7th March 2007, 17:59
  4. c++, placement delete upon exception
    By stinos in forum General Programming
    Replies: 6
    Last Post: 31st October 2006, 15:38
  5. QSqlQueryModel + set Write
    By raphaelf in forum Qt Programming
    Replies: 7
    Last Post: 5th June 2006, 08:55

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.