Page 2 of 2 FirstFirst 12
Results 21 to 30 of 30

Thread: QLineEdit set min max range?

  1. #21
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QLineEdit set min max range?

    You can use the subclassed line edit widget by promoting it as custom widget in the designer. See the context menu of the line edit.
    J-P Nurmi

  2. The following user says thank you to jpn for this useful post:

    whitefurrows (10th June 2006)

  3. #22
    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,

    thank you that's work, but i have one more problem MyLineEdit keep focus if intermediate but if i press button "Save" can i save the data(that's wrong) and MyLineEdit keep focus.

    Is that OK? What can i do?

    Greetings,

    Whitefurrows

  4. #23
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QLineEdit set min max range?

    Sorry, what's the problem? You'll have to explain a bit more clearly. "Can I save the data" is quite an abstract concept..
    J-P Nurmi

  5. The following user says thank you to jpn for this useful post:

    whitefurrows (10th June 2006)

  6. #24
    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?

    Sorry, ok i try it. I have many QLineEdit's on a QWidget and a Button. When the user push the butten, then store the programm the values from the QlineEdit's to the database. The user can store the data always, but that is wrong. I wont the user can save the data only if all QlineEdit's contain right values?

    You know what i mean?

  7. #25
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QLineEdit set min max range?

    You could check the validator states whenever QLineEdit::textChanged() signal is emitted. Or you could emit signals (sending state as a parameter) from the validators whenever they are asked to validate. There are many possibilities... But anyway, you have to somehow keep track of the validator states and enable/disable the button when appropriate.

    Edit: just a side note.. have you looked the possibility of using for example QSqlTableModel + QTableView and a custom delegate to provide suitable editor..?
    Last edited by jpn; 5th June 2006 at 20:22.
    J-P Nurmi

  8. The following user says thank you to jpn for this useful post:

    whitefurrows (10th June 2006)

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

    Default Re: QLineEdit set min max range?

    Hi,

    thank you. I know how can i check the validator states whenever QLineEdit::textChanged() signal is emitted and enable/disable the button.

    I have one last question, i think it's better the QLineEdit can't lost focus as long as the validator states = Intermediate and the user can do nothing else.

    You kow how can i do that?

    Thanks in advance,

    Whitefurrows

  10. #27
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QLineEdit set min max range?

    It's not possible to prevent user from pressing the button by forcing the focus to a line edit. If you ever have to prevent user from doing something, disabling widgets (or blocking with a modal dialog) is the way to go in most cases.

    I get the feeling that there is some misunderstanding of the concept "focus" here. A widget having focus just receives all keyboard input events (unless some other widget has grabbed the keyboard, but that's a whole different story). You can still eg. mouse click over any other widget and so on..
    J-P Nurmi

  11. The following user says thank you to jpn for this useful post:

    whitefurrows (10th June 2006)

  12. #28
    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

  13. #29
    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 

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

    whitefurrows (10th June 2006)

  15. #30
    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.