Results 1 to 20 of 30

Thread: QLineEdit set min max range?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2006
    Posts
    108
    Thanks
    35
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: QLineEdit set min max range?

    Hi,

    sorry the late answer, but i have a long time read the doc and written code. I thing the right way is disabling widgets.

    I do this to check QValidator::State:

    Qt Code:
    1. int pos = 0;
    2. QValidator::State state;
    3. QList<QLineEdit *> leList= this->findChildren<QLineEdit *>();
    4. for (int i=0;i<leList.size();i++){
    5. state = leList[i]->validator()->validate(leList[i]->text(), pos);
    6. if(state == QValidator::Intermediate && leList[i]->text() != ""){
    7. //disabling widgets
    8. }
    9. }
    To copy to clipboard, switch view to plain text mode 

    That's worke fine, but i get a error if a QLineEdit without QValidator.

    How can i check if QLineEdit Validator set, or you know a other solution?

    Greetings,

    Whitefurrows

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QLineEdit set min max range?

    Quote Originally Posted by whitefurrows
    How can i check if QLineEdit Validator set, or you know a other solution?
    const QValidator * QLineEdit::validator () const
    Returns a pointer to the current input validator, or 0 if no validator has been set.
    So this should work:
    Qt Code:
    1. ...
    2. QList<QLineEdit *> leList= this->findChildren<QLineEdit *>();
    3. for (int i=0;i<leList.size();i++){
    4. if( leList[i]->validator() != 0 ) {
    5. state = leList[i]->validator()->validate(leList[i]->text(), pos);
    6. ...
    7. }
    8. }
    To copy to clipboard, switch view to plain text mode 

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

    whitefurrows (10th June 2006)

  4. #3
    Join Date
    May 2006
    Posts
    108
    Thanks
    35
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Thumbs up Re: QLineEdit set min max range?

    Hi,

    now work all fine. Thank you very much. Your help was great!!!

    Greetings,

    Whitefurrows

Similar Threads

  1. Replies: 10
    Last Post: 12th February 2009, 07:23
  2. QLineEdit
    By rick_st3 in forum Newbie
    Replies: 1
    Last Post: 14th June 2008, 09:05
  3. Pointer Question related to QLineEdit
    By ChrisReath in forum Qt Programming
    Replies: 1
    Last Post: 23rd May 2008, 15:13
  4. QValidator, regular expressions and QLineEdit
    By hvengel in forum Qt Programming
    Replies: 1
    Last Post: 8th August 2007, 01:25
  5. Qt and MySQL Database Connection
    By shamik in forum Qt Programming
    Replies: 41
    Last Post: 6th October 2006, 12:48

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
  •  
Qt is a trademark of The Qt Company.