Results 1 to 2 of 2

Thread: QMainWindow how to know when focus lost?

  1. #1
    Join Date
    Feb 2010
    Posts
    1
    Qt products
    Platforms
    Unix/X11

    Default QMainWindow how to know when focus lost?

    Hi everybody! i'm trying to write a program on a pyqt4, on my ubuntu.
    I have QMainWindow with text field and button on it, and i need to know when the user stops working with my window, and switches to other(not mine) window, i've tryed to use focusOutEvent for QMainWindow but it does not work, please tell me what im doing wrong.

    Qt Code:
    1. class TranslateView(QMainWindow):
    2. def __init__(self, parent=None):
    3. QMainWindow.__init__(self, parent)
    4. def focusOutEvent(self, event):
    5. print "out"
    To copy to clipboard, switch view to plain text mode 
    thanks in advance, and sorry for my english.

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMainWindow how to know when focus lost?

    From the documentation:

    A widget normally must setFocusPolicy() to something other than Qt.NoFocus in order to receive focus events. (Note that the application programmer can call setFocus() on any widget, even those that do not normally accept focus.)
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

Similar Threads

  1. Focus lost
    By franco.amato in forum Qt Programming
    Replies: 1
    Last Post: 25th January 2010, 22:07
  2. How detective lost focus application ?
    By Torsten in forum Qt Programming
    Replies: 2
    Last Post: 6th August 2008, 14:19
  3. QLineEdit lost focus
    By codebehind in forum Newbie
    Replies: 5
    Last Post: 4th May 2007, 16:02
  4. Focus issues / Setting multiple focus
    By ComputerPhreak in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2007, 06:09
  5. Replies: 3
    Last Post: 8th September 2006, 18:54

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.