首页 > 解决方案 > Query which QT element has focus

问题描述

Is it possible to query which QT element currently has focus?

I'm currently working with a program and the action I want to implement requires a specific element to have focus. Instead of trying to track down through the hierarchy from the top which element I need, I'm wondering if it's possible to select the element in the UI and then query it so that I can trace it's path upwards.

标签: qt

解决方案


If you want to know that QWidget has the focus then use the QApplication::focusWidget() method, you can also use the focusChanged signal


推荐阅读