本文整理汇总了Python中PyQt4.QtSql.QSqlTableModel.revertAll方法的典型用法代码示例。如果您正苦于以下问题:Python QSqlTableModel.revertAll方法的具体用法?Python QSqlTableModel.revertAll怎么用?Python QSqlTableModel.revertAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtSql.QSqlTableModel
的用法示例。
在下文中一共展示了QSqlTableModel.revertAll方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MainWindow
# 需要导入模块: from PyQt4.QtSql import QSqlTableModel [as 别名]
# 或者: from PyQt4.QtSql.QSqlTableModel import revertAll [as 别名]
#.........这里部分代码省略.........
self.sModel.setData(self.sModel.index(row, SQT),
QVariant(1))
self.sModel.setData(self.sModel.index(row, SDESC),
QVariant(""))
self.editindex = self.sModel.index(row, SQT)
self.sTableView.setCurrentIndex(self.editindex)
self.sTableView.edit(self.editindex)
def delDettRecord(self):
if not self.db.isOpen():
self.statusbar.showMessage(
"Database non aperto...",
5000)
return
selrows = self.sItmSelModel.selectedRows()
if not selrows:
self.statusbar.showMessage(
"No articles selected to delete...",
5000)
return
if(QMessageBox.question(self, "Cancellazione righe",
"Vuoi cancellare: {0} righe?".format(len(selrows)),
QMessageBox.Yes|QMessageBox.No) ==
QMessageBox.No):
return
QSqlDatabase.database().transaction()
query = QSqlQuery()
query.prepare("DELETE FROM ddtslave WHERE id = :val")
for i in selrows:
if i.isValid():
query.bindValue(":val", QVariant(i.data().toInt()[0]))
query.exec_()
QSqlDatabase.database().commit()
self.sModel.revertAll()
self.mmUpdate()
def setupMenu(self):
# AboutBox
self.connect(self.action_About, SIGNAL("triggered()"),
self.showAboutBox)
# FileNew
self.connect(self.action_New_File, SIGNAL("triggered()"),
self.newFile)
# FileLoad
self.connect(self.action_Load_File, SIGNAL("triggered()"),
self.openFile)
# Edit Customers
self.connect(self.action_Add_Customers, SIGNAL("triggered()"),
self.editCustomers)
def editCustomers(self):
relpath = os.path.dirname(__file__)
if relpath:
relpath = "%s/" % relpath
subprocess.call(['python',os.path.join("%s../clienti/" %
relpath, "clienti.py")])
self.setupModels()
self.setupMappers()
self.setupTables()
self.mmUpdate()
def showAboutBox(self):
dlg = aboutddt.AboutBox(self)