Results 1 to 2 of 2

Thread: focus out event and cursor issue

  1. #1
    Join Date
    Jan 2011
    Posts
    212
    Thanks
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default focus out event and cursor issue

    Hello forum,

    i have a line edit and i want to do some validation check upon the focus out event. If the validation returns a false i show a message box set the focus back to the line edit and the cursor as well. Otherwise the focus moves along with the cursor to the other widget in the layout.I am over-ridding the focusOutEvent() function as follows:

    This is the minimal example i think

    Qt Code:
    1. void H3DNodeDEFLineEdit::focusOutEvent(QFocusEvent *event)
    2. {
    3. if(event->reason() == Qt::TabFocusReason)
    4. {
    5. QMessageBox msgBox;
    6. msgBox.setText("Tab for the focus out event");
    7. msgBox.exec();
    8.  
    9. }
    10. }
    To copy to clipboard, switch view to plain text mode 

    Now i am having the following behavior:

    With the tab key i get the message box and the focus moves to another widget along with the cursor. But the current line edit still holds the focus and the cursor. How to remove this ?


    Thanks
    Sajjad

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: focus out event and cursor issue

    Why not use QValidator?

Similar Threads

  1. QGraphcisView issue with mouse cursor image
    By dpatel in forum Qt Programming
    Replies: 0
    Last Post: 20th July 2010, 07:28
  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. Replies: 2
    Last Post: 16th January 2010, 04:22
  4. QTableView focus issue
    By gemidjy in forum Qt Programming
    Replies: 4
    Last Post: 19th February 2008, 15:51
  5. focus issue
    By samirg in forum Qt Programming
    Replies: 1
    Last Post: 1st September 2007, 01: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.