Reputation: 19085
I have a rather complex widget structure which representes a list of some objects. The containing frame reacts to some QKeyEvent
s (such as Alt+Up
) which the child widgets don't process themselves. When I receive the event, however, I would like to know where it originated, either by
I cannot handle QKeyEvents
in those widgets, since they know nothing about the parent's functionality -- specifically, Alt-Up
moves an item up in the list, but the item's editor does not itself know it is inside a list.
Upvotes: 1
Views: 108
Reputation: 19085
Got it:
# get focus with keyboard focus
widget=QApplication.focusWidget()
# use its middle position
globPos=widget.mapToGlobal(QPoint(.5*w.width(),.5*w.height()))
Upvotes: 1