Results 1 to 3 of 3

Thread: QSting replace not working

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

    Default QSting replace not working

    Hi everybody.

    QT 4.1.3 Win MINGW

    I am trying to replace "'"with "\'" but its not working

    Have somebody a idea why not?

    Don't musst be Don\'t after replacing
    Qt Code:
    1. //style = Don't
    2. QString style = ui.add_new_style_le->text();
    3. QString test = style.replace(QString("'"), QString("\'"));
    4. //test = Don't and not Don\'t :crying:
    5. QMessageBox::information(this,"",test);
    To copy to clipboard, switch view to plain text mode 
    Think DigitalGasoline

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: QSting replace not working

    "\" is an escape character and must be escaped itself it not used as an escape char:
    Qt Code:
    1. str.replace("'", "\\'");
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  3. The following 2 users say thank you to jpn for this useful post:

    hyling (2nd November 2006), raphaelf (24th October 2006)

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

    Default Re: QSting replace not working

    Hi jpn`

    thanks it works!!
    Think DigitalGasoline

Similar Threads

  1. Connect not working
    By xgoan in forum Qt Programming
    Replies: 4
    Last Post: 24th July 2006, 11:27
  2. Replies: 1
    Last Post: 11th June 2006, 22:25
  3. Mac OS X UI not working
    By hvengel in forum Qt Programming
    Replies: 3
    Last Post: 1st April 2006, 01:02
  4. Signals/Slots stopped working
    By Jimmy2775 in forum Qt Programming
    Replies: 8
    Last Post: 31st March 2006, 21:11
  5. QSettings - beginReadArray not working
    By Mike in forum Qt Programming
    Replies: 7
    Last Post: 9th January 2006, 21:24

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.