本文整理汇总了Python中python_qt_binding.QtGui.QApplication.widgetAt方法的典型用法代码示例。如果您正苦于以下问题:Python QApplication.widgetAt方法的具体用法?Python QApplication.widgetAt怎么用?Python QApplication.widgetAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类python_qt_binding.QtGui.QApplication
的用法示例。
在下文中一共展示了QApplication.widgetAt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _widget_at
# 需要导入模块: from python_qt_binding.QtGui import QApplication [as 别名]
# 或者: from python_qt_binding.QtGui.QApplication import widgetAt [as 别名]
def _widget_at(self, global_point):
#print '_widget_at()', global_point#, local_point
widget = QApplication.widgetAt(global_point)
#print '- widget', widget, (widget.objectName() if widget is not None else '')
root_main_window = self._container_manager.get_root_main_window()
# work around bug where root main window is detected when point is near but not inside it
if widget == root_main_window and not self._widget_contains(root_main_window, global_point):
#print '- work around to large root main window'
widget = None
# work around bug where dock widget is floating and no widget is found
if widget is None and self.isFloating():
# determine all main windows which match the point
overlapping = {}
for main_window in self._main_windows:
if self._widget_contains(main_window, global_point):
parent = main_window.parent()
is_floating = parent is None or parent.isFloating()
overlapping[main_window] = is_floating
#print 'overlapping', overlapping
if len(overlapping) == 1:
# only found one candidate so pick it
widget, _ = overlapping.popitem()
elif len(overlapping) > 1:
# try to determine which main window is the right one
# determined docked main windows
overlapping_docked = [mw for mw, floating in overlapping.iteritems() if not floating]
#print 'overlapping_docked', overlapping_docked
# if at max one of the main windows is floating
if len(overlapping_docked) >= len(overlapping) - 1:
# the floating main window is not considered because the docked ones are children of it
# consider all docked main windows and remove parent if both parent and child are in the list
#print 'considered docked main windows', overlapping_docked
parents = []
for mw1 in overlapping_docked:
# parent of the main window is a dock widget container
parent = mw1.parent()
if parent is None:
continue
# parent of the dock widget container is a main window
parent = parent.parent()
if parent is None:
continue
for mw2 in overlapping_docked:
if mw2 == parent:
parents.append(mw2)
for parent in parents:
overlapping_docked.remove(parent)
#print 'considered non-parent main windows', overlapping_docked
# if only one docked main window is found then pick it
if len(overlapping_docked) == 1:
#print '- pick single remaining main window'
widget = overlapping_docked[0]
else:
#print '- found multiple main windows - could not determine which one is on top'
pass
# TODO any more heuristic possible?
# if all remaining docked main windows have a most common ancestor use the order of children() to determine topmost
return widget