本文整理汇总了Python中AnyQt.QtWidgets.QAction.setData方法的典型用法代码示例。如果您正苦于以下问题:Python QAction.setData方法的具体用法?Python QAction.setData怎么用?Python QAction.setData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtWidgets.QAction
的用法示例。
在下文中一共展示了QAction.setData方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createActionForItem
# 需要导入模块: from AnyQt.QtWidgets import QAction [as 别名]
# 或者: from AnyQt.QtWidgets.QAction import setData [as 别名]
def createActionForItem(self, item):
"""Create the QAction instance for item.
"""
action = QAction(item.icon(), item.text(), self,
toolTip=item.toolTip())
action.setData(item)
return action
示例2: createActionForItem
# 需要导入模块: from AnyQt.QtWidgets import QAction [as 别名]
# 或者: from AnyQt.QtWidgets.QAction import setData [as 别名]
def createActionForItem(self, index):
"""Create the QAction instance for item at `index` (`QModelIndex`).
"""
action = QAction(
item_icon(index), item_text(index), self,
toolTip=item_tooltip(index)
)
action.setData(QPersistentModelIndex(index))
return action
示例3: create_action_for_item
# 需要导入模块: from AnyQt.QtWidgets import QAction [as 别名]
# 或者: from AnyQt.QtWidgets.QAction import setData [as 别名]
def create_action_for_item(self, item):
"""
Create a QAction instance for the widget description item.
"""
name = item.text()
tooltip = item.toolTip()
whatsThis = item.whatsThis()
icon = item.icon()
if icon:
action = QAction(icon, name, self, toolTip=tooltip,
whatsThis=whatsThis,
statusTip=name)
else:
action = QAction(name, self, toolTip=tooltip,
whatsThis=whatsThis,
statusTip=name)
widget_desc = item.data(self.WIDGET_DESC_ROLE)
action.setData(widget_desc)
action.setProperty("item", item)
return action
示例4: addTab
# 需要导入模块: from AnyQt.QtWidgets import QAction [as 别名]
# 或者: from AnyQt.QtWidgets.QAction import setData [as 别名]
def addTab(self, widget, text, toolTip=None, icon=None):
if self.__macUnified:
action = QAction(text, self)
if toolTip:
action.setToolTip(toolTip)
if icon:
action.setIcon(toolTip)
action.setData(len(self.tab.actions()))
self.tab.addAction(action)
self.stack.addWidget(widget)
else:
i = self.tab.addTab(widget, text)
if toolTip:
self.tab.setTabToolTip(i, toolTip)
if icon:
self.tab.setTabIcon(i, icon)
示例5: makeaction
# 需要导入模块: from AnyQt.QtWidgets import QAction [as 别名]
# 或者: from AnyQt.QtWidgets.QAction import setData [as 别名]
def makeaction(text, parent, data=None, **kwargs):
action = QAction(text, parent, **kwargs)
if data is not None:
action.setData(data)
return action