Results 1 to 5 of 5

Thread: QString argument ignoring new line characters

  1. #1
    Join Date
    Jul 2011
    Posts
    31
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3
    Platforms
    MacOS X

    Default QString argument ignoring new line characters

    Hi,

    I am using a QStringList with a few strings and passing the required string as an argument. I am also changing the parameters of the string in css i.e using pstyle and font color size etc. when I pass a string with new line characters the Qstring is displayed in one line instead of multiple lines, however if i put a <br> in the string then it ignores all the css parameters and just puts a break. Can anyone point me in the right direction.

    Thanks

  2. #2
    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: QString argument ignoring new line characters

    It would be nice if you said what you were talking about.
    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.


  3. #3
    Join Date
    Jul 2011
    Posts
    31
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3
    Platforms
    MacOS X

    Default Re: QString argument ignoring new line characters

    Hi wyotsa,

    Sorry anyway here is the setup i had:

    Qt Code:
    1. Labels.at(i)->setText(QString("<p style=\" font-family: SansSerif; font-size: 10pt;margin-left: 20px; \">%1</p>").arg(Names.at(i)));
    To copy to clipboard, switch view to plain text mode 

    I was trying to put new line characters into the argument "Names" but they were ignored. I figured out that a <br /> works once I looked at the Rich text documentation , please let me know if there is a better solution.

    Thanks

  4. #4
    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: QString argument ignoring new line characters

    Linebreaks will be ignored when using rich text. <br/> is the way to go. However the best solution would be to use multiple labels or a list view.
    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.


  5. #5
    Join Date
    Jul 2011
    Posts
    31
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3
    Platforms
    MacOS X

    Default Re: QString argument ignoring new line characters

    Cool, oh this was just a way to have the text on the label so that its visible on multiple lines based on the length of text.

Similar Threads

  1. Replies: 2
    Last Post: 11th August 2011, 15:42
  2. QString::arg: Argument missing
    By BalaQT in forum Qt Programming
    Replies: 3
    Last Post: 4th May 2011, 14:57
  3. QString with escape characters
    By Jeffb in forum Newbie
    Replies: 1
    Last Post: 26th April 2010, 14:06
  4. Replies: 11
    Last Post: 11th October 2007, 16:34
  5. Warning QString::arg() argument missing
    By quickNitin in forum Newbie
    Replies: 9
    Last Post: 16th November 2006, 19:13

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.