Results 1 to 4 of 4

Thread: how to force QLineEdit not null ?

  1. #1

    Default how to force QLineEdit not null ?

    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!

  2. #2
    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: how to force QLineEdit not null ?

    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).
    J-P Nurmi

  3. #3

    Default Re: how to force QLineEdit not null ?

    ok, I understand.
    but I still want to know how?
    thanks!

  4. #4
    Join Date
    Aug 2006
    Posts
    221
    Thanks
    3
    Thanked 29 Times in 19 Posts

    Default Re: how to force QLineEdit not null ?

    Quote Originally Posted by jpn View Post
    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?

Similar Threads

  1. Pointer Question related to QLineEdit
    By ChrisReath in forum Qt Programming
    Replies: 1
    Last Post: 23rd May 2008, 15:13
  2. QValidator, regular expressions and QLineEdit
    By hvengel in forum Qt Programming
    Replies: 1
    Last Post: 8th August 2007, 01:25
  3. nmake problems while building mysql driver
    By MarkoSan in forum Installation and Deployment
    Replies: 27
    Last Post: 25th May 2007, 12:57
  4. Problem at time compilation in traslation of language
    By thomasjoy in forum Qt Programming
    Replies: 3
    Last Post: 22nd May 2007, 14:18
  5. QT4 beginner Fatal Error
    By Remyfr in forum Installation and Deployment
    Replies: 3
    Last Post: 11th March 2006, 01: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.