Results 1 to 2 of 2

Thread: LineEdit should not accept only zero's

  1. #1
    Join Date
    Jul 2012
    Posts
    40
    Qt products
    Qt4 Qt/Embedded

    Default LineEdit should not accept only zero's

    Hi,
    I have lineEdit which should accepts only integers and float values,so using QRegExp rxacres( "^[0-9.]*$" ) i controlled it.
    Now this lineEdit should not accept only zero's,i mean like this 0 , 000, 00.000 , 0.000
    For not accepting 0 or 0000 or 00 i have written some logic and its working fine ,i can write for 0.00 or 00.00.......... But i just want to know by using inbulit methods or through QRegExp can we control this Behaviour or not ...?


    Regards
    Beginner

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: LineEdit should not accept only zero's

    Hi,

    musn't the "." be escapled? and then simple do
    pcre Code:
    1. ^([0-9]*[1-9]+[0-9\\.]*|[0-9\\.]*[0-9]*[1-9]+[0-9]*)$
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Accept/Not accept symbols in QLineEdit
    By naturalpsychic in forum Qt Programming
    Replies: 2
    Last Post: 28th March 2012, 16:26
  2. How to set QLineEdit to accept only ASCII...
    By cydside in forum Qt Programming
    Replies: 3
    Last Post: 7th December 2011, 08:55
  3. Replies: 3
    Last Post: 21st December 2010, 14:51
  4. accept() and reject() slots
    By poporacer in forum Newbie
    Replies: 3
    Last Post: 19th August 2010, 01:07
  5. QFileDialog accept() slot is not accessable
    By bigg in forum Qt Programming
    Replies: 4
    Last Post: 29th April 2008, 10:35

Tags for this Thread

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.