Results 1 to 1 of 1

Thread: focusChanged signal being called numerous times every time I click on a widget?

  1. #1

    Default focusChanged signal being called numerous times every time I click on a widget?

    EDIT WITH SOLUTION:
    The problem was simple. I connected to focusChanged in my custom line edit classes, so for every custom line edit, my slot was being called whenever a focusChanged event came in.

    Moderators: feel free to delete this post.


    Original post below:

    I have an app using QT 5.6.1 that I want to open the Windows Virtual Keyboard if a user clicks on a CustomLineEdit, and close the keyboard if the user clicks anywhere else.

    To do this, I have the focusChanged signal connected to a slot that checks if the "now" widget is a custom line edit, if so it opens the keyboard, if not, it closes the keyboard.

    However, I noticed that this was very laggy, so I added a print statement, and here's what I see every time I click on a custom line edit:

    Qt Code:
    1. FocusChanged. previous: 00000000 current: 053B4DD0
    2. FocusChanged. previous: 00000000 current: 053B4DD0
    3. FocusChanged. previous: 00000000 current: 053B4DD0
    4. FocusChanged. previous: 00000000 current: 053B4DD0
    5. FocusChanged. previous: 00000000 current: 053B4DD0
    6. FocusChanged. previous: 00000000 current: 053B4DD0
    7. FocusChanged. previous: 00000000 current: 053B4DD0
    8. FocusChanged. previous: 00000000 current: 053B4DD0
    9. FocusChanged. previous: 00000000 current: 053B4DD0
    10. FocusChanged. previous: 00000000 current: 053B4DD0
    11. FocusChanged. previous: 053B4DD0 current: 08964B00
    12. FocusChanged. previous: 053B4DD0 current: 08964B00
    13. FocusChanged. previous: 053B4DD0 current: 08964B00
    14. FocusChanged. previous: 053B4DD0 current: 08964B00
    15. FocusChanged. previous: 053B4DD0 current: 08964B00
    16. FocusChanged. previous: 053B4DD0 current: 08964B00
    17. FocusChanged. previous: 053B4DD0 current: 08964B00
    18. FocusChanged. previous: 053B4DD0 current: 08964B00
    19. FocusChanged. previous: 053B4DD0 current: 08964B00
    20. FocusChanged. previous: 053B4DD0 current: 08964B00
    To copy to clipboard, switch view to plain text mode 

    Is there a reason this is being called so many times?

    Is there anything I can do short from keeping track of the last time I saw a focusChanged event and filtering duplicates?
    Last edited by aondra; 24th January 2017 at 22:07. Reason: Found the solution

Similar Threads

  1. canFetchMore is getiing called 3 times ??
    By prasad_N in forum Qt Programming
    Replies: 6
    Last Post: 12th October 2015, 15:07
  2. QResizeEvent called 3 times
    By mvbhavsar in forum Newbie
    Replies: 5
    Last Post: 17th December 2014, 16:06
  3. Qt bug? Signal emitted once, slot called multiple times
    By MattPhillips in forum Qt Programming
    Replies: 22
    Last Post: 1st December 2010, 22:32
  4. filterAcceptRows() is being called many times for same souceRow.
    By kaushal_gaurav in forum Qt Programming
    Replies: 2
    Last Post: 19th February 2009, 03:49
  5. Replies: 5
    Last Post: 12th January 2006, 15:40

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.