Results 1 to 5 of 5

Thread: doubt in QLabel

  1. #1
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default doubt in QLabel

    i need to display the below text in QLabel
    "The text will be plain text. Setting the text clears any previous content."
    Qt Code:
    1. label->setText(" The text will be plain text. Setting the text clears any previous content.");
    2. label4->setWordWrap(true);
    To copy to clipboard, switch view to plain text mode 
    i getting the output in label
    Qt Code:
    1. The text will be plain text. Setting the text clears
    2. any previous content.
    To copy to clipboard, switch view to plain text mode 
    but i need the output
    Qt Code:
    1. The text will be plain text.
    2. Setting the text clears any previous content.
    To copy to clipboard, switch view to plain text mode 
    i need this output in twoline.please guide me to get proper result

  2. #2
    Join Date
    Feb 2014
    Posts
    60
    Thanks
    4
    Thanked 5 Times in 5 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: doubt in QLabel

    use \n (escape sequence) wherever you require.In your example

    label->setText(" The text will be plain text.\n Setting the text clears any previous content.");
    label->setWordWrap(true);

  3. The following user says thank you to anbu01 for this useful post:

    iswaryasenthilkumar (13th July 2015)

  4. #3
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: doubt in QLabel

    Qt Code:
    1. label->setText(QString("The text will be plain text.") + QString(QChar::LineFeed) + QString("Setting the text clears any previous content."));
    To copy to clipboard, switch view to plain text mode 

  5. The following user says thank you to Radek for this useful post:

    iswaryasenthilkumar (13th July 2015)

  6. #4
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: doubt in QLabel

    i got error when i use Linefeed,instead of the i used lineseparator its work and fine
    Quote Originally Posted by Radek View Post
    Qt Code:
    1. label->setText(QString("The text will be plain text.") + QString(QChar::LineFeed) + QString("Setting the text clears any previous content."));
    To copy to clipboard, switch view to plain text mode 

  7. #5
    Join Date
    Feb 2014
    Posts
    60
    Thanks
    4
    Thanked 5 Times in 5 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: doubt in QLabel

    @ishwarya
    can you say what error you get on using lineFeed(suggested by Radek) because it works fine for me.

Similar Threads

  1. i have a doubt in qt
    By iswaryasenthilkumar in forum Newbie
    Replies: 7
    Last Post: 12th May 2015, 09:55
  2. geting QLabel text ontop of other QLabel displaying image
    By krystosan in forum Qt Programming
    Replies: 1
    Last Post: 15th December 2013, 18:35
  3. Doubt about QLabel * usage.
    By chobin in forum Newbie
    Replies: 2
    Last Post: 19th July 2013, 12:41
  4. Replies: 1
    Last Post: 29th September 2009, 20:44
  5. Replies: 1
    Last Post: 2nd August 2008, 16:46

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.