Results 1 to 3 of 3

Thread: focusChanged() not working for me.

  1. #1
    Join Date
    Dec 2008
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default focusChanged() not working for me.

    Hi, maybe you can tell me what I'm doing wrong. Using Qt4 PyQt. I get no errors but my slot/handler never fires.

    Thanks for looking - this is driving me nuts.

    Qt Code:
    1. #MainApplication.py
    2. from PyQt4.QtGui import QApplication
    3. from PyQt4 import QtCore
    4.  
    5. class Application(QApplication):
    6.  
    7. def __init__(self, *args):
    8. QApplication.__init__(self, *args)
    9.  
    10. def setupSignals(self):
    11. print "setting up signals..."
    12. QtCore.QObject.connect(self, QtCore.SIGNAL("focusChanged()"), self.changedFocusSlot)
    13.  
    14. def changedFocusSlot(self, old, now):
    15. print "focus changed"
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. #main.py
    2. #!/usr/bin/python
    3.  
    4. from mainWindowUI import MainWindow
    5. from PyQt4 import QtGui, QtCore
    6. import sys
    7. from MainApplication import Application
    8.  
    9. def main():
    10. app = Application(sys.argv)
    11. wnd = MainWindow()
    12. wnd.show()
    13. wnd.activateWindow()
    14. app.setupSignals()
    15. sys.exit(app.exec_())
    16.  
    17. if __name__ == '__main__':
    18. main()
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: focusChanged() not working for me.

    I am not too familiar with Python or PyQt but I think the problem is with your QObject.connect line.

    The SIGNAL is focusChanged with no parameters but the slot takes 2 parameter. I think the signal should be something like

    Qt Code:
    1. QtCore.SIGNAL("focusChanged(QWidget *, QWidget *)")
    To copy to clipboard, switch view to plain text mode 

    Hope this helps

  3. #3
    Join Date
    Dec 2008
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: focusChanged() not working for me.

    Yay! That works.

    Thought I already tried that and every variation *forehead slap*.

    Thanks a bunch.

Similar Threads

  1. QResource Stopped Working
    By JPNaude in forum Qt Programming
    Replies: 0
    Last Post: 22nd October 2008, 12:26
  2. QCheckBox::isChecked() property is not working...
    By Cutey in forum Qt Programming
    Replies: 10
    Last Post: 18th August 2008, 08:14
  3. QDevelop and CTags -> Not working
    By philwinder in forum Qt-based Software
    Replies: 13
    Last Post: 9th May 2008, 21:40
  4. Don't want QTextBrowser to look in working directory
    By magland in forum Qt Programming
    Replies: 1
    Last Post: 20th October 2007, 23:14
  5. GUI thread and Working thread comunication
    By FasTTo in forum Qt Programming
    Replies: 2
    Last Post: 13th September 2007, 15:31

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
  •  
Qt is a trademark of The Qt Company.