当前位置: 首页>>代码示例>>Python>>正文


Python QStandardItem.setForeground方法代码示例

本文整理汇总了Python中PyQt5.QtGui.QStandardItem.setForeground方法的典型用法代码示例。如果您正苦于以下问题:Python QStandardItem.setForeground方法的具体用法?Python QStandardItem.setForeground怎么用?Python QStandardItem.setForeground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtGui.QStandardItem的用法示例。


在下文中一共展示了QStandardItem.setForeground方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __updateSlotsModel

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setForeground [as 别名]
 def __updateSlotsModel(self):
     """
     Private slot to update the slots tree display.
     """
     self.filterEdit.clear()
     
     try:
         dlg = uic.loadUi(
             self.formFile, package=self.project.getProjectPath())
         objects = dlg.findChildren(QWidget) + dlg.findChildren(QAction)
         
         signatureList = self.__signatures()
         
         self.slotsModel.clear()
         self.slotsModel.setHorizontalHeaderLabels([""])
         for obj in objects:
             name = obj.objectName()
             if not name or name.startswith("qt_"):
                 # ignore un-named or internal objects
                 continue
             
             metaObject = obj.metaObject()
             className = metaObject.className()
             itm = QStandardItem("{0} ({1})".format(name, className))
             self.slotsModel.appendRow(itm)
             for index in range(metaObject.methodCount()):
                 metaMethod = metaObject.method(index)
                 if metaMethod.methodType() == QMetaMethod.Signal:
                     if qVersion() >= "5.0.0":
                         itm2 = QStandardItem("on_{0}_{1}".format(
                             name,
                             bytes(metaMethod.methodSignature()).decode()))
                     else:
                         itm2 = QStandardItem("on_{0}_{1}".format(
                             name, metaMethod.signature()))
                     itm.appendRow(itm2)
                     if self.__module is not None:
                         if qVersion() >= "5.0.0":
                             method = "on_{0}_{1}".format(
                                 name,
                                 bytes(metaMethod.methodSignature())
                                 .decode().split("(")[0])
                         else:
                             method = "on_{0}_{1}".format(
                                 name, metaMethod.signature().split("(")[0])
                         method2 = "{0}({1})".format(
                             method, ", ".join(
                                 [self.__mapType(t)
                                  for t in metaMethod.parameterTypes()]))
                         
                         if method2 in signatureList or \
                                 method in signatureList:
                             itm2.setFlags(Qt.ItemFlags(Qt.ItemIsEnabled))
                             itm2.setCheckState(Qt.Checked)
                             itm2.setForeground(QBrush(Qt.blue))
                             continue
                     
                     returnType = self.__mapType(
                         metaMethod.typeName().encode())
                     if returnType == 'void':
                         returnType = ""
                     parameterTypesList = [
                         self.__mapType(t)
                         for t in metaMethod.parameterTypes()]
                     pyqtSignature = ", ".join(parameterTypesList)
                     
                     parameterNames = metaMethod.parameterNames()
                     if parameterNames:
                         for index in range(len(parameterNames)):
                             if not parameterNames[index]:
                                 parameterNames[index] = \
                                     QByteArray("p{0:d}".format(index)
                                                .encode("utf-8"))
                     parameterNamesList = [bytes(n).decode()
                                           for n in parameterNames]
                     methNamesSig = ", ".join(parameterNamesList)
                     
                     if methNamesSig:
                         if qVersion() >= "5.0.0":
                             pythonSignature = \
                                 "on_{0}_{1}(self, {2})".format(
                                     name,
                                     bytes(metaMethod.methodSignature())
                                     .decode().split("(")[0],
                                     methNamesSig)
                         else:
                             pythonSignature = \
                                 "on_{0}_{1}(self, {2})".format(
                                     name,
                                     metaMethod.signature().split("(")[0],
                                     methNamesSig)
                     else:
                         if qVersion() >= "5.0.0":
                             pythonSignature = "on_{0}_{1}(self)".format(
                                 name,
                                 bytes(metaMethod.methodSignature())
                                 .decode().split("(")[0])
                         else:
                             pythonSignature = "on_{0}_{1}(self)".format(
                                 name,
#.........这里部分代码省略.........
开发者ID:testmana2,项目名称:test,代码行数:103,代码来源:CreateDialogCodeDialog.py


注:本文中的PyQt5.QtGui.QStandardItem.setForeground方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。