Focus on QAction
-
some more details will help here. What is the relation of QAction to other widget ? What is the underlying widget etc.
Also it is good check the focusInEvent handler.
-
the QAction could be tied to multiple widget and i wanted to see if any of the underlying widgets had focus. therefore, i am thinking of doing the following by tying the hovered signal from QAction to a slot with the following coding:
QList <QWidget *> widget_list = sender()->associatedWidgets();
for(i = 0; i != widget_list.size(); ++i) {
if (widget_list.at(i)->hasFocus())
then do something
else
do something else
}i think this will work?
-
Hi,
Indeed, it's not. A QAction doesn't have a "physical" representation. What you could do is create an action manager that would react when your widgets get/lose their focus.
Hope it helps
-
Indeed
An action manager is a central object where you handle e.g. the redirection of the signals and slots based on your current widget or the shortcuts
IIRC, Qt Creator has such a concept, you can have a look at the sources