Results 1 to 3 of 3

Thread: How to send the output(say average) to a lineEdit?

  1. #1
    Join Date
    Jun 2010
    Posts
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Question How to send the output(say average) to a lineEdit?

    Hi everyone. I am new to qt programming.
    I want to compute the average and display the output using a lineEdit.
    I used

    ui->lineEdit->setText(QString::number(avg));
    This displays the output without decimals. How to display float in lineEdit?

    Thanks in advance..

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to send the output(say average) to a lineEdit?

    There are several overloaded QString::number() variants.
    have a looks at this one:
    http://doc.trolltech.com/4.6/qstring.html#number-2
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jun 2010
    Posts
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: How to send the output(say average) to a lineEdit?

    Thanks .
    I got it

    ui->lineEdit->setText(QString::number(avg,'f',2));

Similar Threads

  1. Help on using QTableWidget with LineEdit.
    By narendra in forum Qt Programming
    Replies: 3
    Last Post: 31st December 2009, 15:30
  2. Validate a value of lineEdit
    By edgar in forum Qt Programming
    Replies: 1
    Last Post: 6th September 2009, 18:22
  3. How to update lineEdit
    By HelloDan in forum Qt Programming
    Replies: 9
    Last Post: 17th February 2009, 07:01
  4. Get Color from LineEdit
    By raphaelf in forum Newbie
    Replies: 4
    Last Post: 15th May 2007, 15:30
  5. cursor in LineEdit
    By Jerry in forum Qt Programming
    Replies: 1
    Last Post: 13th August 2006, 21:56

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.