Results 1 to 5 of 5

Thread: simplified alternative

  1. #1
    Join Date
    May 2009
    Location
    Gorontalo
    Posts
    200
    Thanks
    20
    Thanked 5 Times in 5 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Question simplified alternative

    There is a function like simplified but not trim start whitespaces?

  2. #2
    Join Date
    Dec 2012
    Posts
    197
    Thanks
    25
    Thanked 41 Times in 33 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: simplified alternative

    Nothin that i am aware off but you can always try something.
    Like just use the simplified function over the substring that doesn't contain the start-whitespaces. ( you can find several ways to get that substring )

    Good Luck.

  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: simplified alternative

    Quote Originally Posted by wirasto View Post
    There is a function like simplified but not trim start whitespaces?
    Qt Code:
    1. QRegExp rx("(\\s*[^\\s]+)");
    2. rx.match(string);
    3. QString simplified = rx.cap(1);
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: simplified alternative

    That will give you the first "word" and any leading whitespace, but not subsequent words with whitespace runs collapsed to single spaces as simplified() does (if you use QRegularExpression::match() or QRegExp::indexIn()).

  5. #5
    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: simplified alternative

    True. However it should work if you allow multiples of such groups. Other than that a simple for loop iterating from the end of the string and chopping off whitespaces is a good approach.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Simplified problem about enums and QVariants.
    By hickscorp in forum Qt Programming
    Replies: 5
    Last Post: 9th August 2011, 10:50
  2. QString sth between trimmed and simplified
    By pmlody in forum Qt Programming
    Replies: 3
    Last Post: 3rd November 2009, 08:13
  3. Problems with QString::simplified() API
    By montylee in forum Qt Programming
    Replies: 2
    Last Post: 20th June 2009, 04:14
  4. Replies: 1
    Last Post: 15th May 2009, 07:16
  5. How to disply Simplified Chinese in QTextBrowser
    By xjtu in forum Qt Programming
    Replies: 1
    Last Post: 21st April 2008, 08:15

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.