本文整理汇总了Python中PyQt4.Qt.QTableView.selectedIndexes方法的典型用法代码示例。如果您正苦于以下问题:Python QTableView.selectedIndexes方法的具体用法?Python QTableView.selectedIndexes怎么用?Python QTableView.selectedIndexes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qt.QTableView
的用法示例。
在下文中一共展示了QTableView.selectedIndexes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MainWidget
# 需要导入模块: from PyQt4.Qt import QTableView [as 别名]
# 或者: from PyQt4.Qt.QTableView import selectedIndexes [as 别名]
#.........这里部分代码省略.........
self.ZMatModel.setItem(i, j, QStandardItem())
self.ZMatModel.item(i, j).setBackground(QColor(150,150,150))
self.ZMatModel.item(i, j).setFlags(Qt.ItemIsEnabled)
def populateFreqModel(self):
self.FreqModel.removeRows(0, self.FreqModel.rowCount())
for i, row in enumerate(zip(self.vibfreqs, self.vibirs, self.vibramans)):
for j, cell in enumerate(row):
item = QStandardItem(str(cell))
self.FreqModel.setItem(i, j, item)
# add a row to the bottom of the ZMatModel
def addRow(self):
# temporarily stop updating the GL window
self.ZMatModel.dataChanged.disconnect(self.clearUpdateView)
row = self.ZMatModel.rowCount()
self.ZMatModel.insertRow(row)
# some cells should not be editable
if row < 3:
for j in range(2*row+1, 7):
self.ZMatModel.setItem(row, j, QStandardItem())
self.ZMatModel.item(row, j).setBackground(QColor(150,150,150))
self.ZMatModel.item(row, j).setFlags(Qt.ItemIsEnabled)
# restart GL window updating
self.ZMatModel.dataChanged.connect(self.clearUpdateView)
self.statusBar.clearMessage()
self.statusBar.showMessage('Added 1 row.', 3000)
# delete the last row of the ZMatModel
def deleteRow(self):
xyz = [list(vi) for vi in list(v)]
atoms = [str(elements[e]) for e in elems]
oldLen = self.ZMatModel.rowCount()
idxs = sorted(set(idx.row() for idx in self.ZMatTable.selectedIndexes()), reverse=True)
newLen = oldLen - len(idxs)
if newLen == oldLen:
self.ZMatModel.removeRow(self.ZMatModel.rowCount()-1)
else:
self.ZMatModel.dataChanged.disconnect(self.clearUpdateView)
for idx in idxs:
self.ZMatModel.removeRow(idx)
if idx < 3:
for i in range(idx, min(3, newLen)):
for j in range(2*i+1, 7):
self.ZMatModel.setItem(i, j, QStandardItem())
self.ZMatModel.item(i, j).setBackground(QColor(150,150,150))
self.ZMatModel.item(i, j).setFlags(Qt.ItemIsEnabled)
if len(xyz) > idx:
xyz.pop(idx)
atoms.pop(idx)
self.inp = xyz2zmat(xyz, atoms)
self.populateZMatModel()
for i in reversed(self.highList):
self.window.removeItem(i[1])
self.highList = []
self.ZMatModel.dataChanged.connect(self.clearUpdateView)
self.updateView()
self.statusBar.clearMessage()
if idxs:
self.statusBar.showMessage('Deleted row(s): '+str([i+1 for i in idxs]), 3000)
else:
self.statusBar.showMessage('Deleted last row.', 3000)
# show the periodic table widget
def periodicTable(self):
self.statusBar.clearMessage()
示例2: PluginObject
# 需要导入模块: from PyQt4.Qt import QTableView [as 别名]
# 或者: from PyQt4.Qt.QTableView import selectedIndexes [as 别名]
#.........这里部分代码省略.........
self.segOrdListBox = QListWidget()
self.segOrdListBox.customContextMenuRequested.connect(self.showOrdContextMenu)
self.segOrdListBox.setContextMenuPolicy(Qt.CustomContextMenu)
self.searchButton = QPushButton("Search")
self.main.connect(self.searchButton, SIGNAL('clicked()'), searchForPassphrase)
self.stopButton = QPushButton("Stop Searching")
self.stopButton.setEnabled(False)
self.main.connect(self.stopButton, SIGNAL('clicked()'), endSearch)
totalSearchLabel = QRichLabel(tr("""<b>Total Passphrase Tries To Search: </b>"""), doWrap=False)
self.totalSearchTriesDisplay = QLineEdit()
self.totalSearchTriesDisplay.setReadOnly(True)
self.totalSearchTriesDisplay.setText(QString('0'))
self.totalSearchTriesDisplay.setFont(GETFONT('Fixed'))
self.totalSearchTriesDisplay.setMinimumWidth(tightSizeNChar(self.totalSearchTriesDisplay, 6)[0])
self.totalSearchTriesDisplay.setMaximumWidth(tightSizeNChar(self.totalSearchTriesDisplay, 12)[0])
searchButtonPanel = makeHorizFrame([self.searchButton, self.stopButton, 'stretch', totalSearchLabel, self.totalSearchTriesDisplay])
self.resultsDisplay = QTextEdit()
self.resultsDisplay.setReadOnly(True)
self.resultsDisplay.setFont(GETFONT('Fixed'))
self.resultsDisplay.setMinimumHeight(100)
self.searchPanel = makeVertFrame([topRow, self.segDefTableView, orderingButtonPanel,
self.segOrdListBox, searchButtonPanel, self.resultsDisplay, 'stretch'])
# Now set the scrollarea widget to the layout
self.tabToDisplay = QScrollArea()
self.tabToDisplay.setWidgetResizable(True)
self.tabToDisplay.setWidget(self.searchPanel)
def getSelectedWlt(self):
wlt = None
selectedWltList = self.main.walletsView.selectedIndexes()
if len(selectedWltList)>0:
row = selectedWltList[0].row()
wltID = str(self.main.walletsView.model().index(row, WLTVIEWCOLS.ID).data().toString())
wlt = self.main.walletMap[wltID]
return wlt
def showSegContextMenu(self):
menu = QMenu(self.segDefTableView)
if len(self.segDefTableView.selectedIndexes())==0:
return
row = self.segDefTableView.selectedIndexes()[0].row()
deleteSegMenuItem = menu.addAction("Delete Segment")
action = menu.exec_(QCursor.pos())
if action == deleteSegMenuItem:
self.deleteSegRow(row)
def showOrdContextMenu(self):
menu = QMenu(self.segOrdListBox)
if len(self.segOrdListBox.selectedItems())==0:
return
item = self.segOrdListBox.currentItem()
deleteOrdMenuItem = menu.addAction("Delete Ordering")
action = menu.exec_(QCursor.pos())
if action == deleteOrdMenuItem:
self.deleteOrdItem(item)
def deleteSegRow(self, row):
self.segDefList.remove(self.segDefList[row])