Results 1 to 13 of 13

Thread: Insertion double quote into string/qstring

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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: Insertion double quote into string/qstring

    Quote Originally Posted by MarkoSan View Post
    Yep, I do. Let me give you complete code:
    Qt Code:
    1. [...]
    2. queryString.arg(strPicPath);
    3. [...]
    To copy to clipboard, switch view to plain text mode 
    To me it looks you don't. Notice that QString::arg() is a const method. Again, it does not modify the original value but returns a modified value.
    J-P Nurmi

  2. #2
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanks
    111
    Thanked 4 Times in 4 Posts

    Default Re: Insertion double quote into string/qstring

    I have this system everywhere in project and it works fine, just here it does not work. So, how should I rewrite the code, have you any clues?
    Qt 5.3 Opensource & Creator 3.1.2

  3. #3
    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: Insertion double quote into string/qstring

    Quote Originally Posted by MarkoSan View Post
    I have this system everywhere in project and it works fine, just here it does not work. So, how should I rewrite the code, have you any clues?
    Give yourself a moment to think it. Consider the following piece of pseudo code:
    Qt Code:
    1. QString QString::arg(value) const
    2. {
    3. // does not modify _this_ but returns a copy
    4. QString copy(*this);
    5. copy.replacePlaceHolderWithValue(value);
    6. return copy;
    7. }
    To copy to clipboard, switch view to plain text mode 

    What's the content of foo?
    Qt Code:
    1. QString foo("%1");
    2. foo.arg(1234);
    To copy to clipboard, switch view to plain text mode 

    What's the content of bar?
    Qt Code:
    1. QString bar("%1");
    2. bar = bar.arg(5678);
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  4. #4
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanks
    111
    Thanked 4 Times in 4 Posts

    Default Re: Insertion double quote into string/qstring

    foo has 1234

    and bar has 5678

    Am I right?
    Qt 5.3 Opensource & Creator 3.1.2

  5. #5
    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: Insertion double quote into string/qstring

    Quote Originally Posted by MarkoSan View Post
    foo has 1234

    and bar has 5678

    Am I right?
    Unfortunately not (foo has "%1" and bar has "5678"). However, did you notice the difference? Looks subtle, but is in fact significant.
    J-P Nurmi

  6. The following user says thank you to jpn for this useful post:

    MarkoSan (14th December 2007)

  7. #6
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanks
    111
    Thanked 4 Times in 4 Posts

    Smile Re: Insertion double quote into string/qstring

    Aha, I must use = operator to set right value. God damn, thanks.
    Qt 5.3 Opensource & Creator 3.1.2

Similar Threads

  1. Double Click Capturing
    By ToddAtWSU in forum Qt Programming
    Replies: 2
    Last Post: 8th January 2011, 14:12
  2. double record insertion
    By tranfuga25s in forum Qt Programming
    Replies: 4
    Last Post: 9th September 2006, 17:12

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.