Results 1 to 3 of 3

Thread: Porting suggest3=>4 Q3CString::stripWhiteSpace() QByteArray::trimmed()

  1. #1
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Porting suggest3=>4 Q3CString::stripWhiteSpace() QByteArray::trimmed()

    Why QByteArray::trimmed() not replace all space? (stripWhiteSpace qt3 word)

    Qt Code:
    1. QString Setting_Gui::FullTrimSpace(QString cutestrings)
    2. {
    3. QByteArray cleanpolice;
    4. cleanpolice.append(cutestrings.trimmed()); /* QString trimmed start & end */
    5. cleanpolice.trimmed(); /* porting suggest3=>4 Q3CString::stripWhiteSpace() QByteArray::trimmed() */
    6. return cleanpolice.data();
    7. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Porting suggest3=>4 Q3CString::stripWhiteSpace() QByteArray::trimmed()

    Solved so work....

    Qt Code:
    1. QString Setting_Gui::FullTrimSpace(QString cutestrings)
    2. {
    3. QStringList list = cutestrings.split(" ");
    4. QString newpola = list.join("");
    5. return newpola.trimmed();
    6. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Porting suggest3=>4 Q3CString::stripWhiteSpace() QByteArray::trimmed()

    how about:

    Qt Code:
    1. QString str;
    2. //...
    3. str.remove(' ');
    To copy to clipboard, switch view to plain text mode 

    Should work a lot faster.

  4. The following user says thank you to wysota for this useful post:

    TCB13 (28th August 2011)

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.