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


Python QAbstractTableModel.setData方法代码示例

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


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

示例1: setData

# 需要导入模块: from PyQt4.QtCore import QAbstractTableModel [as 别名]
# 或者: from PyQt4.QtCore.QAbstractTableModel import setData [as 别名]
 def setData(self, index, value, role):
     if not index.isValid(): return False
     
     # get attribute name for this column
     attribute = self.sections[index.column()]
     # get the object
     loan = self.loans[index.row()]
     
     # save the change
     if role == Qt.EditRole:
         # remember, value is a QVariant!!
         
         # ok, these lookups should probably be done once, in __init__
         if index.column() in [ 
             self.position_for_header('item_description'),
             self.position_for_header('item_type'),
             self.position_for_header('person') ]:
                 value = unicode(value.toString())
         elif index.column() in [ 
             self.position_for_header('date'),
             self.position_for_header('expected_date') ]:
                 value = value.toDateTime().toPyDateTime()
         elif index.column() == self.IDCOL:
             value = str(value.toString())
                 
         loan[attribute] = value
         self.save() # this might have to go elsewhere
         self.dataChanged.emit(index,index)
         return True
         
     # for everything else, do the generic thing
     return QAbstractTableModel.setData(self,index,value,role)
开发者ID:toyg,项目名称:plasmaapplets,代码行数:34,代码来源:gsbmodels.py

示例2: setData

# 需要导入模块: from PyQt4.QtCore import QAbstractTableModel [as 别名]
# 或者: from PyQt4.QtCore.QAbstractTableModel import setData [as 别名]
    def setData(self, index, value, role):
        """ Reimplemented to allow setting data.
        """
        if role == Qt.EditRole:
            # This works because a Facets Editor will have already set the value
            # on the object, and so we don't need to do anything here:
            return True

        return QAbstractTableModel.setData(self, index, value, role)
开发者ID:davidmorrill,项目名称:facets,代码行数:11,代码来源:grid_editor.py

示例3: setData

# 需要导入模块: from PyQt4.QtCore import QAbstractTableModel [as 别名]
# 或者: from PyQt4.QtCore.QAbstractTableModel import setData [as 别名]
 def setData(self, index, value, role):
     if role == Qt.EditRole and index.isValid():
         task = self.todoList[index.row()]
         if index.column() == 0:
             if value == self.trUtf8("未开始"):
                 task["finishment"] = 0
             elif value == self.trUtf8("已完成"):
                 task["finishment"] = 100
             else:
                 task["finishment"] = 50
         else:
             assert index.column() == 1
             task["subject"] = value
         self.dataChanged.emit(index, index)
         self.taskUpdated.emit(task["id"])
         return True
     return QAbstractTableModel.setData(self, index, value, role)
开发者ID:OSUser,项目名称:quickpanel,代码行数:19,代码来源:todo_list.py

示例4: setData

# 需要导入模块: from PyQt4.QtCore import QAbstractTableModel [as 别名]
# 或者: from PyQt4.QtCore.QAbstractTableModel import setData [as 别名]
    def setData (self, modelIndex, variant, role=Qt.EditRole):
        # not length or filepath and editing
        if modelIndex.column ()<7 and role==Qt.EditRole:
            logger.debug ("QPLM.setData()", modelIndex.row (), modelIndex.column(), role, ">%s<", unicode (variant.toString ()))
            song= self.collaggr.songForIndex (modelIndex.row ())
            attr= self.attrNames[modelIndex.column ()]
            try:
                song[attr]= unicode (variant.toString ())
                # TODO: make a list of dirty songs and commit them later
                song.saveMetadata ()
            except TagWriteError:
                # it failed
                ans= False
            else:
                self.edited= True
                self.dataChanged.emit (modelIndex, modelIndex)
                ans= True
        else:
            ans= QAbstractTableModel.setData (self, modelIndex, variant, role)

        logger.debug ("QPLM.setData():", modelIndex.row(), modelIndex.column (), role, ans)
        return ans
开发者ID:StyXman,项目名称:satyr,代码行数:24,代码来源:complex.py


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