Results 1 to 5 of 5

Thread: settext

  1. #1
    Join Date
    Sep 2010
    Posts
    22
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default settext

    i have a very easy question. how can i settext an int value??

    Qt Code:
    1. int length;
    2. length=10;
    3. ui->lineEdit->setText("The length is:", length);
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: settext

    Qt Code:
    1. ui->lineEdit->setText(QString("The length is: %1").arg(length));
    To copy to clipboard, switch view to plain text mode 

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

    seltra (3rd October 2010)

  4. #3
    Join Date
    Sep 2010
    Posts
    22
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: settext

    Quote Originally Posted by tbscope View Post
    Qt Code:
    1. ui->lineEdit->setText(QString("The length is: %1").arg(length));
    To copy to clipboard, switch view to plain text mode 
    thank you very much tbscope.
    how can i setText with only the integer value?
    Qt Code:
    1. ui->lineEdit->setText(arg(length));
    To copy to clipboard, switch view to plain text mode 

  5. #4
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: settext

    Qt Code:
    1. ui->lineEdit->setText(QString("%1").arg(length));
    To copy to clipboard, switch view to plain text mode 

    Or, and better:
    Qt Code:
    1. ui->lineEdit->setText(QString::number(length));
    To copy to clipboard, switch view to plain text mode 

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

    seltra (3rd October 2010)

  7. #5
    Join Date
    Sep 2010
    Posts
    22
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: settext

    that helped me thank you very much.

Similar Threads

  1. setText translation
    By weixj2003ld in forum Qt Programming
    Replies: 4
    Last Post: 20th April 2009, 15:59
  2. QAction and setText
    By babu198649 in forum Newbie
    Replies: 3
    Last Post: 4th February 2009, 14:32
  3. setText and html
    By mattia in forum Newbie
    Replies: 11
    Last Post: 31st January 2008, 19:10
  4. More CPU Load when using SetText
    By arunvv in forum Newbie
    Replies: 3
    Last Post: 23rd January 2008, 19:35
  5. setText not working
    By MarkoSan in forum Qt Programming
    Replies: 4
    Last Post: 11th January 2006, 13:05

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.