Results 1 to 3 of 3

Thread: Need to implement in place line edit, unable to get lose focus of QLineEdit.

  1. #1
    Join Date
    Apr 2011
    Posts
    4
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi PyQt3 PyQt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Need to implement in place line edit, unable to get lose focus of QLineEdit.

    I'm working on a custom Qt line edit that allows you to edit the text only if you double click it. When it is double clicked, QLineEdit is getting enabled for text editing. Once you press enter or tab it gets in read only mode again.

    One more requirement which I want to implement - is that if the user clicks anywhere in the application window or outside application window, the QLineEdit should become read only again(it should leave the edit mode). This works in some cases. Specifically, it works if I click on anything that is capable of text entry. Other portions of the window don't work as expected.

    If I'll click on a blank portion(parent frame) of the application window, QLineEdit retains its focus. How can I remove its focus in these cases?

    Actually the problem is I am not getting focusOut when clicking outside on parent window? Can you give me proper direction please...

  2. #2
    Join Date
    Apr 2011
    Posts
    61
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Need to implement in place line edit, unable to get lose focus of QLineEdit.

    You can set your window to receive focus.
    setFocusPolicy(Qt::StrongFocus);

  3. #3
    Join Date
    Apr 2011
    Posts
    4
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi PyQt3 PyQt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Need to implement in place line edit, unable to get lose focus of QLineEdit.

    Thanks a lot! It fixed my problem! But I want to know little bit more if there is any side affect of setting strong focus on main window.

Similar Threads

  1. Forcing a QWidget to lose focus
    By Polnareff in forum Qt Programming
    Replies: 1
    Last Post: 5th November 2010, 10:24
  2. Is there focus event for line edit?
    By vjsharma_30 in forum Qt Programming
    Replies: 6
    Last Post: 19th February 2010, 20:12
  3. line edit focus
    By addu in forum Qt Programming
    Replies: 3
    Last Post: 16th July 2009, 15:39
  4. i want to lose the focus...
    By jrodway in forum Qt Programming
    Replies: 7
    Last Post: 14th July 2007, 10:04
  5. QCanvas automatically lose its focus.
    By Cutey in forum Qt Programming
    Replies: 1
    Last Post: 19th January 2007, 11:29

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.