Results 1 to 8 of 8

Thread: DocuMentation item

  1. #1
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default DocuMentation item

    Hi,
    In the documentation for Qt-4.4,l at
    http://doc.trolltech.com/4.4/qstring.html#replace
    I think? there might be a minor error?
    QString & QString::replace ( int position, int n, const QString & after )
    Replaces n characters from the specified index position with the string after, and returns a reference to this string.
    Example:
    QString x = "Say yes!";
    QString y = "no";
    x.replace(4, 3, y);
    // x == "Say no!"
    I think there should be an "!" after the "no".

    As an old man that has trouble reading "coded" instructions, I find these little examples very, very helpful. I just wish there were more of them.

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: DocuMentation item

    Quote Originally Posted by impeteperry View Post
    I think there should be an "!" after the "no".
    There is one.

  3. #3
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: DocuMentation item

    I see "yes!"
    and
    I see "no"
    where is the "!" in "no"?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: DocuMentation item

    Quote Originally Posted by impeteperry View Post
    where is the "!" in "no"?
    Here:
    // x == "Say no!"
    I've just cut & pasted the above line from the docs.

  5. #5
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: DocuMentation item

    OK, I went back to my example, and low and behold I understand!

    Stasting with the 4th charter, you are replacing the next 3 characters (yes) with the second string (no)

    Thanks very much for your kind indulgence, I feel like a fool

  6. #6
    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: DocuMentation item

    Errare humanum est

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

    impeteperry (1st September 2008)

  8. #7
    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: DocuMentation item

    Why not use .arg() method?

    Qt Code:
    1. QString x = QString("Say %1!");
    2. ...
    3. use x.arg("yes");
    4. or
    5. use x.arg("no");
    To copy to clipboard, switch view to plain text mode 
    I'm a rebel in the S.D.G.

  9. #8
    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: DocuMentation item

    Because it's the documentation of QString::replace, not QString::arg.

Similar Threads

  1. View, Scene, Item and thread??
    By dungsivn in forum Qt Programming
    Replies: 5
    Last Post: 20th August 2008, 19:21
  2. Item in a DLL not getting events
    By Benne Gesserit in forum Qt Programming
    Replies: 11
    Last Post: 16th August 2008, 22:30
  3. Item Delegate Painting
    By stevey in forum Qt Programming
    Replies: 3
    Last Post: 9th May 2008, 07:37
  4. Replies: 1
    Last Post: 19th April 2007, 22:23
  5. how change the QListBox item position by pixel
    By roy_skyx in forum Qt Programming
    Replies: 2
    Last Post: 20th January 2006, 01:34

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.