PDA

View Full Version : how to force QLineEdit not null ?



lovelypp
24th July 2008, 15:06
I have a QLineEdit on a Widget. when the QLineEdit lost focus, I want to ensure the content of QLineEdit is not null . If it is null, it prompts "you should input something" and then renturns the focus to QLineEdit. How ?
thanks!

jpn
24th July 2008, 16:33
Please do not try to force focus anywhere. It is considered as bad UI design. Just disable the button to proceed (or whatever is suitable in your case).

lovelypp
25th July 2008, 08:09
ok, I understand.
but I still want to know how?
thanks!

Kumosan
25th July 2008, 09:26
Please do not try to force focus anywhere. It is considered as bad UI design. Just disable the button to proceed (or whatever is suitable in your case).

Probably it is very often bad UI design. But what do you think of this possibly rare use case:

You have to enter:
data 1
data 2
data 3
data 4

Suppose data 2 is optional and for most users not necessary. Perhaps some address appendage. I would jump from data 1 directly to data 3. Some sort of 80/20 solution. For 80% it saves a mouse click to skip this unnecessary field, for 20% it means a click more to actively set the cursor back into data 2.

Of course, I could always reorder data 1 - 4, but this might look funny for addresses.

Acceptable?