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
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
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
whitefurrows (11th June 2006)
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?
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 21:22.
J-P Nurmi
whitefurrows (11th June 2006)
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
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
whitefurrows (11th June 2006)
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:
int pos = 0; QList<QLineEdit *> leList= this->findChildren<QLineEdit *>(); for (int i=0;i<leList.size();i++){ state = leList[i]->validator()->validate(leList[i]->text(), pos); //disabling widgets } }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
Originally Posted by whitefurrows
So this should work:const QValidator * QLineEdit::validator () const
Returns a pointer to the current input validator, or 0 if no validator has been set.Qt Code:
... QList<QLineEdit *> leList= this->findChildren<QLineEdit *>(); for (int i=0;i<leList.size();i++){ if( leList[i]->validator() != 0 ) { state = leList[i]->validator()->validate(leList[i]->text(), pos); ... } }To copy to clipboard, switch view to plain text mode
whitefurrows (11th June 2006)
Hi,
now work all fine. Thank you very much. Your help was great!!!
Greetings,
Whitefurrows
Bookmarks