Results 1 to 4 of 4

Thread: set the range in textedit

  1. #1
    Join Date
    Aug 2012
    Posts
    16
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default set the range in textedit

    How to set the range ie,(115.0 to 200.0) in textedit?

  2. #2
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: set the range in textedit

    hi,
    u can use spin box for setting the range.
    Qt Code:
    1. QSpinBox *sp = new QSpinBox;
    2. sp->setRange(115.0,200.0);
    To copy to clipboard, switch view to plain text mode 
    why u r using text edit?

    for reading the value from spinBox
    Qt Code:
    1. sp->value();
    To copy to clipboard, switch view to plain text mode 
    for setting the value in spinbox
    sp->setValue();

    Hope it helps
    Bala

  3. #3
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: set the range in textedit

    Or if you really need text edit use QLineEdit and setValidator, also see QDoubleValidator

    LE: a small issue with BalaQT's answer is that you need QDoubleSpinBox class QSpinBox uses only int's

  4. #4
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: set the range in textedit

    LE: a small issue with BalaQT's answer is that you need QDoubleSpinBox class QSpinBox uses only int's
    thanks zlatomir for correcting me
    Bala

Similar Threads

  1. QDoubleVlaidator range
    By johnmauer in forum Qt Programming
    Replies: 1
    Last Post: 20th October 2010, 16:08
  2. Out of range detection
    By zgulser in forum Qt Programming
    Replies: 2
    Last Post: 6th February 2009, 09:32
  3. Index out of Range
    By santhoshv84 in forum Qt Programming
    Replies: 2
    Last Post: 19th August 2008, 15:33
  4. QLineEdit set min max range?
    By whitefurrows in forum Qt Programming
    Replies: 29
    Last Post: 10th June 2006, 23:51
  5. Elements out of Range!!
    By Kapil in forum Newbie
    Replies: 9
    Last Post: 3rd April 2006, 10:28

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.