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


Python QTableWidgetItem.setData方法代码示例

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


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

示例1: populate_tbl_helper

# 需要导入模块: from PyQt4.Qt import QTableWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTableWidgetItem import setData [as 别名]
 def populate_tbl_helper(hsgui, tbl, col_headers, col_editable, row_list, row2_data_tup ):
     #tbl = main_skel.chip_TBL
     hheader = tbl.horizontalHeader()
     sort_col = hheader.sortIndicatorSection()
     sort_ord = hheader.sortIndicatorOrder()
     tbl.sortByColumn(0, Qt.AscendingOrder) # Basic Sorting
     prevBlockSignals = tbl.blockSignals(True)
     tbl.clear()
     tbl.setColumnCount(len(col_headers))
     tbl.setRowCount(len(row_list))
     tbl.verticalHeader().hide()
     tbl.setHorizontalHeaderLabels(col_headers)
     tbl.setSelectionMode( QAbstractItemView.SingleSelection )
     tbl.setSelectionBehavior( QAbstractItemView.SelectRows)
     tbl.setSortingEnabled(False)
     for row in iter(row_list):
         data_tup = row2_data_tup[row]
         for col, data in enumerate(data_tup):
             item = QTableWidgetItem()
             try:
                 int_data = int(data)
                 item.setData(Qt.DisplayRole, int_data)
             except ValueError: # for strings
                 item.setText(str(data))
             except TypeError: #for lists
                 item.setText(str(data))
             item.setTextAlignment(Qt.AlignHCenter)
             if col_editable[col]: item.setFlags(item.flags() | Qt.ItemIsEditable)
             else: item.setFlags(item.flags() ^ Qt.ItemIsEditable)
             tbl.setItem(row, col, item)
     tbl.setSortingEnabled(True)
     tbl.sortByColumn(sort_col,sort_ord) # Move back to old sorting
     tbl.show()
     tbl.blockSignals(prevBlockSignals)
开发者ID:Erotemic,项目名称:hotspotter,代码行数:36,代码来源:MainWindow.py

示例2: actualizarCompeticiones

# 需要导入模块: from PyQt4.Qt import QTableWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTableWidgetItem import setData [as 别名]
 def actualizarCompeticiones(self):
     cont = 0
     self.tbCompeticion.setRowCount(0)
     for k in self.listaCompeticiones:
         self.tbCompeticion.setRowCount(self.tbCompeticion.rowCount()+1)
         nameFile = str(k[5])+'.png'
         dirIco = str(self.config.profile('INFO_GENERAL','DIRRECURSOS'))+'/flags/'+nameFile
         itemBandera = QTableWidgetItem(QIcon(dirIco),"",1)
         competicion = self.existComp(k[1])
         itemCompeticionT = QTableWidgetItem()
         if competicion:
             itemBandera.setCheckState(Qt.Checked)
             itemCompeticionT.setData(Qt.DisplayRole,competicion)
         else:
             itemBandera.setCheckState(Qt.Unchecked)
             itemCompeticionT.setData(Qt.DisplayRole,"")
         itemBandera.setData(Qt.DisplayRole,"")
         self.tbCompeticion.setItem(cont, 0,itemBandera)
         self.tbCompeticion.setItem(cont, 2,itemCompeticionT)
         itemCompeticion = QTableWidgetItem()
         itemCompeticion.setData(Qt.DisplayRole,k[1])
         self.tbCompeticion.setItem(cont, 1,itemCompeticion)  
         itemID = QTableWidgetItem()
         itemID.setData(Qt.DisplayRole,k[0])
         self.tbCompeticion.setItem(cont, 3,itemID) 
         cont += 1
     self.tbCompeticion.selectRow(self.rowCompSelected)
开发者ID:jbustio,项目名称:LiveScore,代码行数:29,代码来源:mainWindow.py

示例3: actualizarJuegos

# 需要导入模块: from PyQt4.Qt import QTableWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTableWidgetItem import setData [as 别名]
 def actualizarJuegos(self):
     cont = 0
     if self.tbCompeticion.currentItem():
         row = self.tbCompeticion.currentItem().row()
         idCompeticion = self.tbCompeticion.item(row, 3).text()
     else:
         row = 0
         idCompeticion = self.listaCompeticiones[0][0]
     
     self.tbJuegos.setRowCount(0)
     for k in self.listaJuegos:
         if k[19] == idCompeticion:
             self.tbJuegos.setRowCount(self.tbJuegos.rowCount()+1)
             itemHora = QTableWidgetItem()
             itemHora.setData(Qt.DisplayRole,k[5])
             self.tbJuegos.setItem(cont, 0,itemHora)
             itemTiempo = QTableWidgetItem()
             itemTiempo.setData(Qt.DisplayRole,k[7])
             self.tbJuegos.setItem(cont, 1,itemTiempo)
             itemEq1 = QTableWidgetItem()
             itemEq1.setData(Qt.DisplayRole,k[1])
             self.tbJuegos.setItem(cont, 2,itemEq1)  
             itemResult = QTableWidgetItem()
             cad = k[11]+':'+k[12]
             itemResult.setData(Qt.DisplayRole,cad)
             self.tbJuegos.setItem(cont, 3,itemResult)  
             itemEq2 = QTableWidgetItem()
             itemEq2.setData(Qt.DisplayRole,k[2])
             self.tbJuegos.setItem(cont, 4,itemEq2)
             cont += 1
开发者ID:jbustio,项目名称:LiveScore,代码行数:32,代码来源:mainWindow.py

示例4: __init__

# 需要导入模块: from PyQt4.Qt import QTableWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTableWidgetItem import setData [as 别名]
    def __init__(self, parent, items):
        QDialog.__init__(self, parent)
        Ui_DeleteMatchingFromDeviceDialog.__init__(self)
        self.setupUi(self)

        self.explanation.setText('<p>'+_('All checked books will be '
                                   '<b>permanently deleted</b> from your '
                                   'device. Please verify the list.')+'</p>')
        self.buttonBox.accepted.connect(self.accepted)
        self.buttonBox.rejected.connect(self.rejected)
        self.table.cellClicked.connect(self.cell_clicked)
        self.table.setSelectionMode(QAbstractItemView.NoSelection)
        self.table.setColumnCount(7)
        self.table.setHorizontalHeaderLabels(
                                    ['', _('Location'), _('Title'), _('Author'),
                                      _('Date'), _('Format'), _('Path')])
        rows = 0
        for card in items:
            rows += len(items[card][1])
        self.table.setRowCount(rows)
        row = 0
        for card in items:
            (model,books) = items[card]
            for (id,book) in books:
                item = QTableWidgetItem()
                item.setFlags(Qt.ItemIsUserCheckable|Qt.ItemIsEnabled)
                item.setCheckState(Qt.Checked)
                item.setData(Qt.UserRole, (model, id, book.path))
                self.table.setItem(row, 0, item)
                self.table.setItem(row, 1, tableItem(card))
                self.table.setItem(row, 2, titleTableItem(book.title))
                self.table.setItem(row, 3, authorTableItem(book))
                self.table.setItem(row, 4, dateTableItem(book.datetime))
                self.table.setItem(row, 5, centeredTableItem(book.path.rpartition('.')[2]))
                self.table.setItem(row, 6, tableItem(book.path))
                row += 1
        self.table.setCurrentCell(0, 1)
        self.table.resizeColumnsToContents()
        self.table.setSortingEnabled(True)
        self.table.sortByColumn(2, Qt.AscendingOrder)
        self.table.setCurrentCell(0, 1)
开发者ID:089git,项目名称:calibre,代码行数:43,代码来源:delete_matching_from_device.py

示例5: setData

# 需要导入模块: from PyQt4.Qt import QTableWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTableWidgetItem import setData [as 别名]
 def setData(self, role, data):
     if role == Qt.EditRole:
         self.previous_value = self.current_value
         self.current_value = data.toString()
     QTableWidgetItem.setData(self, role, data)
开发者ID:Eksmo,项目名称:calibre,代码行数:7,代码来源:tag_list_editor.py


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