Results 1 to 3 of 3

Thread: how to show a intger value in LineEdit

  1. #1
    Join Date
    Mar 2011
    Location
    delhi
    Posts
    45
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Exclamation how to show a intger value in LineEdit

    hi all please tell me,how can i do:following
    if i enter a int value in LineEdit1 and second int value in LineEdit2 add and perform addition operation on two int value and result should be show in LineEdit3;


    thanks with regards:
    gauravg

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: how to show a intger value in LineEdit

    How about you show us what you have tried and explain where your difficulty is.

    Apart from sounding a lot like a basic assignment the requirement is a bit vague. When should the addition occur? What should happen if the user types a non-number into a edit box?

  3. #3
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how to show a intger value in LineEdit

    Vague question, vague answer:
    Qt Code:
    1. LineEdit3->setText( QString::number( LineEdit1->text().toInt() + LineEdit2->text().toInt() ) );
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 3
    Last Post: 12th July 2010, 13:12
  2. LineEdit.
    By Rewo in forum Newbie
    Replies: 17
    Last Post: 2nd July 2010, 09:37
  3. lineEdit's setSelection - How to show more text?
    By squidge in forum Qt Programming
    Replies: 3
    Last Post: 30th January 2010, 17:22
  4. Slots in LineEdit
    By Misko in forum Newbie
    Replies: 3
    Last Post: 28th July 2007, 13:36
  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.