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


Python QSqlTableModel.setData方法代码示例

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


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

示例1: setData

# 需要导入模块: from PyQt4.QtSql import QSqlTableModel [as 别名]
# 或者: from PyQt4.QtSql.QSqlTableModel import setData [as 别名]
 def setData(self, index, value, role=Qt.EditRole):
     """
     Custom reimplementation of the method setData.
     It is necessary to work with value map and value relation.
     index: column index to be set
     value: value to be set
     role: role used
     """
     column = self.headerData(index.column(), Qt.Horizontal)
     newValue = value
     if self.dict.has_key(column):
         if isinstance(self.dict[column], dict):
             valueMap = self.dict[column]
             newValue = int(valueMap[value])
         elif isinstance(self.dict[column], tuple):
             tupla = self.dict[column]
             valueMap = self.makeValueRelationDict(tupla[0], tupla[1])
             code_names = value[1:-1].split(',')
             codes = []
             for code_name in code_names:
                 code = valueMap[code_name]
                 codes.append(code)
             if len(codes) > 0:
                 newValue = '{%s}' % ','.join(map(str, codes))
     return QSqlTableModel.setData(self, index, newValue, role)
开发者ID:lcoandrade,项目名称:DsgTools,代码行数:27,代码来源:manageComplex.py

示例2: setData

# 需要导入模块: from PyQt4.QtSql import QSqlTableModel [as 别名]
# 或者: from PyQt4.QtSql.QSqlTableModel import setData [as 别名]
 def setData(self, index, value, role=Qt.EditRole):
     column = self.headerData(index.column(), Qt.Horizontal)
     newValue = value
     if self.dict.has_key(column):
         dict = self.dict[column]
         newValue = int(dict[value])
     return QSqlTableModel.setData(self, index, newValue, role)
开发者ID:HydroLogic,项目名称:DsgTools,代码行数:9,代码来源:manageComplex.py

示例3: setData

# 需要导入模块: from PyQt4.QtSql import QSqlTableModel [as 别名]
# 或者: from PyQt4.QtSql.QSqlTableModel import setData [as 别名]
 def setData(self, index, value, role=Qt.EditRole):
     column = self.headerData(index.column(), Qt.Horizontal)
     newValue = value
     if self.dict.has_key(column):
         if isinstance(self.dict[column], dict):
             valueMap = self.dict[column]
             newValue = int(valueMap[value])
         elif isinstance(self.dict[column], tuple):
             tupla = self.dict[column]
             valueMap = self.makeValueRelationDict(tupla[0], tupla[1])
             code_names = value[1:-1].split(',')
             codes = []
             for code_name in code_names:
                 code = valueMap[code_name]
                 codes.append(code)
             if len(codes) > 0:
                 newValue = '{%s}' % ','.join(map(str, codes))
     return QSqlTableModel.setData(self, index, newValue, role)
开发者ID:alexdsz,项目名称:DsgTools,代码行数:20,代码来源:manageComplex.py

示例4: setData

# 需要导入模块: from PyQt4.QtSql import QSqlTableModel [as 别名]
# 或者: from PyQt4.QtSql.QSqlTableModel import setData [as 别名]
 def setData(self, index, value, role):
     if index.column() == 2 and role == Qt.CheckStateRole:
         return QSqlTableModel.setData(self, index, QVariant('1' if value == Qt.Checked else '0'), Qt.EditRole)
     return QSqlTableModel.setData(self, index, value, role)
开发者ID:Virlena,项目名称:stoppark_panel,代码行数:6,代码来源:terminal_config.py


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