pyqt4的一些相关资料整理
1 python qt gui 源代码下载
2 qt资料大全
下面的书籍截取自qt资料大全网页,仅供参考
书籍
《QmlBook》 - A Book about Qt5:
- 英文版:http://qmlbook.github.io
- 中文版:https://github.com/cwc1987/QmlBook-In-Chinese
书名:《C++ Primer plus》
作者:Stephen Prata
介绍:从入门到精通必读经典教程。它被誉为“开发人员学习C++的教程,没有之一”!
书名:《C++ Primer》
作者:Stanley B. Lippman、Josee Lajoie、Barbara E. Moo
介绍:久负盛名的经典教程,系统全面地介绍了C++,可以看成是学习C++的百科全书,C++程序猿必备。
书名:《C++ GUI Qt 4编程》
作者:Jasmin Blanchette、Mark Summerfield
介绍:Trolltech的Qt培训教材,生动、全面、深刻地阐明了Qt程序的设计理念,轻松创建跨平台的解决方案。
书名:《Qt高级编程》
作者:Mark Summerfield
介绍:阐述Qt高级编程技术的书籍。以工程实践为主旨,是对Qt现有的700多个类和上百万字参考文档中部分关键技术深入、全面的讲解和探讨。
书名:《Python Qt GUI快速编程》
作者:Mark Summerfield
介绍:讲述如何利用Python和Qt开发GUI应用程序的原理、方法和关键技术。结构合理,内容详实,适合用作对Python、Qt和PyQt编程感兴趣的童鞋。
书名:《C++ Qt设计模式》
作者: Alan Ezust
介绍:利用跨平台开源软件开发框架Qt阐释了C++和设计模式中的主要思想,既复习了设计模式,又学了C++/Qt,对于使用其它框架也是一个非常有用的参考。
书名:《Qt5开发实战》
作者:金大zhen、张红艳 译
介绍:在全面阐述Qt基本功能的基础上,对新增的功能和服务进行了重点介绍。同时运用大量示例,集中讲解了应用程序的开发方法、技巧和必需的API。
书名:《Qt5开发及实例》
作者:陆文周
介绍:以Qt5.4为平台,循序渐进,在介绍开发环境的基础上,系统介绍Qt5应用程序的开发技术,通过实例介绍和讲解内容,将知识和能力融为一体。一般能够在比较短的时间内掌握Qt5应用技术。
书名:《Qt on Android 核心编程》
作者:安晓辉
介绍:基于Qt 5.2,详细讲述如何在移动平台Android上使用Qt框架进行开发。无论是专注于传统的桌面软件开发,还是希望尝试使用Qt在Android平台开发,都可以从中获得重要的知识与实例。
书名:《Qt Quick核心编程》
作者:安晓辉
介绍:着力于QML语言基础、事件、Qt Quick基本元素,辅以简要的ECMAScript(JavaScript)语言介绍,能够快速熟悉Qt Quick的基本知识和开发过程,详尽入微。
书名:《Qt Creator快速入门 》
作者:霍亚飞
介绍:基于Qt Creator编写,全面涉及 Qt Quick;植根于 Qt 网络博客教程,可无限更新;对每个知识点详尽讲解,并设计了示例程序。
书名:《Qt5编程入门》
作者:霍亚飞、devbean
介绍:基于Qt5.3编写,全面涉及 Qt Quick;植根于 Qt 网络博客教程,可无限更新;对每个知识点详尽讲解,并设计了示例程序。
书名:《精通Qt4编程》
作者:蔡志明 等编
介绍:详细介绍了Qt的基础知识和GUI编程应用,举例翔实,内容全面,基本涵盖了Qt编程的各个方面。
书名:《Linux环境下Qt4图形界面与MySQL编程》
作者:邱铁
介绍:基于Qt4.7,采用“深入分析控件+实例解析”的方式,配合实际工程项目,对Linux操作系统下的Qt与MySQL编程技术进行了全面细致的讲解。
书名:《Linux Qt GUI开发详解》
作者:李彬
介绍:介绍了Linux下Qt用户界面开发的重要的核心知识,从基础界面控件使用开始,中间又详细讲解了QtWebKit的开发,语言通俗易懂,通过实例演示强化读者对章节知识点的掌握,以提高读者的实战水平及经验。
书名:《零基础学Qt4编程》
作者:吴迪
介绍:针对初学者写的,很详细,如果看了还不会的话,那也是没谁了!
源码分析
#!/usr/bin/env python
# Copyright (c) 2007-8 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.import os
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtSql import *
import qrc_resourcesMAC = "qt_mac_set_native_menubar" in dir()ID = 0
NAME = ASSETID = 1
CATEGORYID = DATE = DESCRIPTION = 2
ROOM = ACTIONID = 3ACQUIRED = 1def createFakeData():import randomprint "Dropping tables..."query = QSqlQuery()query.exec_("DROP TABLE assets")query.exec_("DROP TABLE logs")query.exec_("DROP TABLE actions")query.exec_("DROP TABLE categories")QApplication.processEvents()print "Creating tables..."query.exec_("""CREATE TABLE actions (id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE NOT NULL,name VARCHAR(20) NOT NULL,description VARCHAR(40) NOT NULL)""")query.exec_("""CREATE TABLE categories (id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE NOT NULL,name VARCHAR(20) NOT NULL,description VARCHAR(40) NOT NULL)""")query.exec_("""CREATE TABLE assets (id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE NOT NULL,name VARCHAR(40) NOT NULL,categoryid INTEGER NOT NULL,room VARCHAR(4) NOT NULL,FOREIGN KEY (categoryid) REFERENCES categories)""")query.exec_("""CREATE TABLE logs (id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE NOT NULL,assetid INTEGER NOT NULL,date DATE NOT NULL,actionid INTEGER NOT NULL,FOREIGN KEY (assetid) REFERENCES assets,FOREIGN KEY (actionid) REFERENCES actions)""")QApplication.processEvents()print "Populating tables..."query.exec_("INSERT INTO actions (name, description) ""VALUES ('Acquired', 'When installed')")query.exec_("INSERT INTO actions (name, description) ""VALUES ('Broken', 'When failed and unusable')")query.exec_("INSERT INTO actions (name, description) ""VALUES ('Repaired', 'When back in service')")query.exec_("INSERT INTO actions (name, description) ""VALUES ('Routine maintenance', ""'When tested, refilled, etc.')")query.exec_("INSERT INTO categories (name, description) VALUES ""('Computer Equipment', ""'Monitors, System Units, Peripherals, etc.')")query.exec_("INSERT INTO categories (name, description) VALUES ""('Furniture', 'Chairs, Tables, Desks, etc.')")query.exec_("INSERT INTO categories (name, description) VALUES ""('Electrical Equipment', 'Non-computer electricals')")today = QDate.currentDate()floors = range(1, 12) + range(14, 28)monitors = (('17" LCD Monitor', 1),('20" LCD Monitor', 1),('21" LCD Monitor', 1),('21" CRT Monitor', 1),('24" CRT Monitor', 1))computers = (("Computer (32-bit/80GB/0.5GB)", 1),("Computer (32-bit/100GB/1GB)", 1),("Computer (32-bit/120GB/1GB)", 1),("Computer (64-bit/240GB/2GB)", 1),("Computer (64-bit/320GB/4GB)", 1))printers = (("Laser Printer (4 ppm)", 1),("Laser Printer (6 ppm)", 1),("Laser Printer (8 ppm)", 1),("Laser Printer (16 ppm)", 1))chairs = (("Secretary Chair", 2),("Executive Chair (Basic)", 2),("Executive Chair (Ergonimic)", 2),("Executive Chair (Hi-Tech)", 2))desks = (("Desk (Basic, 3 drawer)", 2),("Desk (Standard, 3 drawer)", 2),("Desk (Executive, 3 drawer)", 2),("Desk (Executive, 4 drawer)", 2),("Desk (Large, 4 drawer)", 2))furniture = (("Filing Cabinet (3 drawer)", 2),("Filing Cabinet (4 drawer)", 2),("Filing Cabinet (5 drawer)", 2),("Bookcase (4 shelves)", 2),("Bookcase (6 shelves)", 2),("Table (4 seater)", 2),("Table (8 seater)", 2),("Table (12 seater)", 2))electrical = (("Fan (3 speed)", 3),("Fan (5 speed)", 3),("Photocopier (4 ppm)", 3),("Photocopier (6 ppm)", 3),("Photocopier (8 ppm)", 3),("Shredder", 3))query.prepare("INSERT INTO assets (name, categoryid, room) ""VALUES (:name, :categoryid, :room)")logQuery = QSqlQuery()logQuery.prepare("INSERT INTO logs (assetid, date, actionid) ""VALUES (:assetid, :date, :actionid)")assetid = 1for i in range(20):room = QVariant("%02d%02d" % (random.choice(floors),random.randint(1, 62)))for name, category in (random.choice(monitors),random.choice(computers), random.choice(chairs),random.choice(desks), random.choice(furniture)):query.bindValue(":name", QVariant(name))query.bindValue(":categoryid", QVariant(category))query.bindValue(":room", room)query.exec_()logQuery.bindValue(":assetid", QVariant(assetid))when = today.addDays(-random.randint(7, 1500))logQuery.bindValue(":date", QVariant(when))logQuery.bindValue(":actionid", QVariant(ACQUIRED))logQuery.exec_()if random.random() > 0.7:logQuery.bindValue(":assetid", QVariant(assetid))when = when.addDays(random.randint(1, 1500))if when <= today:logQuery.bindValue(":date", QVariant(when))logQuery.bindValue(":actionid",QVariant(random.choice((2, 4))))logQuery.exec_()assetid += 1if random.random() > 0.8:name, category = random.choice(printers)query.bindValue(":name", QVariant(name))query.bindValue(":categoryid", QVariant(category))query.bindValue(":room", room)query.exec_()logQuery.bindValue(":assetid", QVariant(assetid))when = today.addDays(-random.randint(7, 1500))logQuery.bindValue(":date", QVariant(when))logQuery.bindValue(":actionid", QVariant(ACQUIRED))logQuery.exec_()if random.random() > 0.6:logQuery.bindValue(":assetid", QVariant(assetid))when = when.addDays(random.randint(1, 1500))if when <= today:logQuery.bindValue(":date", QVariant(when))logQuery.bindValue(":actionid",QVariant(random.choice((2, 4))))logQuery.exec_()assetid += 1if random.random() > 0.6:name, category = random.choice(electrical)query.bindValue(":name", QVariant(name))query.bindValue(":categoryid", QVariant(category))query.bindValue(":room", room)query.exec_()logQuery.bindValue(":assetid", QVariant(assetid))when = today.addDays(-random.randint(7, 1500))logQuery.bindValue(":date", QVariant(when))logQuery.bindValue(":actionid", QVariant(ACQUIRED))logQuery.exec_()if random.random() > 0.5:logQuery.bindValue(":assetid", QVariant(assetid))when = when.addDays(random.randint(1, 1500))if when <= today:logQuery.bindValue(":date", QVariant(when))logQuery.bindValue(":actionid",QVariant(random.choice((2, 4))))logQuery.exec_()assetid += 1QApplication.processEvents()print "Assets:"query.exec_("SELECT id, name, categoryid, room FROM assets ""ORDER by id")categoryQuery = QSqlQuery()while query.next():id = query.value(0).toInt()[0]name = unicode(query.value(1).toString())categoryid = query.value(2).toInt()[0]room = unicode(query.value(3).toString())categoryQuery.exec_(QString("SELECT name FROM categories ""WHERE id = %1").arg(categoryid))category = "%d" % categoryidif categoryQuery.next():category = unicode(categoryQuery.value(0).toString())print "%d: %s [%s] %s" % (id, name, category, room)QApplication.processEvents()class ReferenceDataDlg(QDialog):def __init__(self, table, title, parent=None):super(ReferenceDataDlg, self).__init__(parent)self.model = QSqlTableModel(self)self.model.setTable(table)self.model.setSort(NAME, Qt.AscendingOrder)self.model.setHeaderData(ID, Qt.Horizontal,QVariant("ID"))self.model.setHeaderData(NAME, Qt.Horizontal,QVariant("Name"))self.model.setHeaderData(DESCRIPTION, Qt.Horizontal,QVariant("Description"))self.model.select()self.view = QTableView()self.view.setModel(self.model)self.view.setSelectionMode(QTableView.SingleSelection)self.view.setSelectionBehavior(QTableView.SelectRows)self.view.setColumnHidden(ID, True)self.view.resizeColumnsToContents()addButton = QPushButton("&Add")deleteButton = QPushButton("&Delete")okButton = QPushButton("&OK")if not MAC:addButton.setFocusPolicy(Qt.NoFocus)deleteButton.setFocusPolicy(Qt.NoFocus)buttonLayout = QHBoxLayout()buttonLayout.addWidget(addButton)buttonLayout.addWidget(deleteButton)buttonLayout.addStretch()buttonLayout.addWidget(okButton)layout = QVBoxLayout()layout.addWidget(self.view)layout.addLayout(buttonLayout)self.setLayout(layout)self.connect(addButton, SIGNAL("clicked()"), self.addRecord)self.connect(deleteButton, SIGNAL("clicked()"),self.deleteRecord)self.connect(okButton, SIGNAL("clicked()"), self.accept)self.setWindowTitle("Asset Manager - Edit %s Reference Data" % title)def addRecord(self):row = self.model.rowCount()self.model.insertRow(row)index = self.model.index(row, NAME)self.view.setCurrentIndex(index)self.view.edit(index)def deleteRecord(self):index = self.view.currentIndex()if not index.isValid():return#QSqlDatabase.database().transaction()record = self.model.record(index.row())id = record.value(ID).toInt()[0]table = self.model.tableName()query = QSqlQuery()if table == "actions":query.exec_(QString("SELECT COUNT(*) FROM logs ""WHERE actionid = %1").arg(id))elif table == "categories":query.exec_(QString("SELECT COUNT(*) FROM assets ""WHERE categoryid = %1").arg(id))count = 0if query.next():count = query.value(0).toInt()[0]if count:QMessageBox.information(self,QString("Delete %1").arg(table),QString("Cannot delete %1<br>""from the %2 table because it is used by ""%3 records") \.arg(record.value(NAME).toString()).arg(table).arg(count))#QSqlDatabase.database().rollback()returnself.model.removeRow(index.row())self.model.submitAll()#QSqlDatabase.database().commit()class AssetDelegate(QSqlRelationalDelegate):def __init__(self, parent=None):super(AssetDelegate, self).__init__(parent)def paint(self, painter, option, index):myoption = QStyleOptionViewItem(option)if index.column() == ROOM:myoption.displayAlignment |= Qt.AlignRight|Qt.AlignVCenterQSqlRelationalDelegate.paint(self, painter, myoption, index)def createEditor(self, parent, option, index):if index.column() == ROOM:editor = QLineEdit(parent)regex = QRegExp(r"(?:0[1-9]|1[0124-9]|2[0-7])"r"(?:0[1-9]|[1-5][0-9]|6[012])")validator = QRegExpValidator(regex, parent)editor.setValidator(validator)editor.setInputMask("9999")editor.setAlignment(Qt.AlignRight|Qt.AlignVCenter)return editorelse:return QSqlRelationalDelegate.createEditor(self, parent,option, index)def setEditorData(self, editor, index):if index.column() == ROOM:text = index.model().data(index, Qt.DisplayRole).toString()editor.setText(text)else:QSqlRelationalDelegate.setEditorData(self, editor, index)def setModelData(self, editor, model, index):if index.column() == ROOM:model.setData(index, QVariant(editor.text()))else:QSqlRelationalDelegate.setModelData(self, editor, model,index)class LogDelegate(QSqlRelationalDelegate):def __init__(self, parent=None):super(LogDelegate, self).__init__(parent)def paint(self, painter, option, index):myoption = QStyleOptionViewItem(option)if index.column() == DATE:myoption.displayAlignment |= Qt.AlignRight|Qt.AlignVCenterQSqlRelationalDelegate.paint(self, painter, myoption, index)def createEditor(self, parent, option, index):if index.column() == ACTIONID and \index.model().data(index, Qt.DisplayRole).toInt()[0] == \ACQUIRED: # Acquired is read-onlyreturnif index.column() == DATE:editor = QDateEdit(parent)editor.setMaximumDate(QDate.currentDate())editor.setDisplayFormat("yyyy-MM-dd")if PYQT_VERSION_STR >= "4.1.0":editor.setCalendarPopup(True)editor.setAlignment(Qt.AlignRight|Qt.AlignVCenter)return editorelse:return QSqlRelationalDelegate.createEditor(self, parent,option, index)def setEditorData(self, editor, index):if index.column() == DATE:date = index.model().data(index, Qt.DisplayRole).toDate()editor.setDate(date)else:QSqlRelationalDelegate.setEditorData(self, editor, index)def setModelData(self, editor, model, index):if index.column() == DATE:model.setData(index, QVariant(editor.date()))else:QSqlRelationalDelegate.setModelData(self, editor, model,index)class MainForm(QDialog):def __init__(self):super(MainForm, self).__init__()self.assetModel = QSqlRelationalTableModel(self)self.assetModel.setTable("assets")self.assetModel.setRelation(CATEGORYID,QSqlRelation("categories", "id", "name"))self.assetModel.setSort(ROOM, Qt.AscendingOrder)self.assetModel.setHeaderData(ID, Qt.Horizontal,QVariant("ID"))self.assetModel.setHeaderData(NAME, Qt.Horizontal,QVariant("Name"))self.assetModel.setHeaderData(CATEGORYID, Qt.Horizontal,QVariant("Category"))self.assetModel.setHeaderData(ROOM, Qt.Horizontal,QVariant("Room"))self.assetModel.select()self.assetView = QTableView()self.assetView.setModel(self.assetModel)self.assetView.setItemDelegate(AssetDelegate(self))self.assetView.setSelectionMode(QTableView.SingleSelection)self.assetView.setSelectionBehavior(QTableView.SelectRows)self.assetView.setColumnHidden(ID, True)self.assetView.resizeColumnsToContents()assetLabel = QLabel("A&ssets")assetLabel.setBuddy(self.assetView)self.logModel = QSqlRelationalTableModel(self)self.logModel.setTable("logs")self.logModel.setRelation(ACTIONID,QSqlRelation("actions", "id", "name"))self.logModel.setSort(DATE, Qt.AscendingOrder)self.logModel.setHeaderData(DATE, Qt.Horizontal,QVariant("Date"))self.logModel.setHeaderData(ACTIONID, Qt.Horizontal,QVariant("Action"))self.logModel.select()self.logView = QTableView()self.logView.setModel(self.logModel)self.logView.setItemDelegate(LogDelegate(self))self.logView.setSelectionMode(QTableView.SingleSelection)self.logView.setSelectionBehavior(QTableView.SelectRows)self.logView.setColumnHidden(ID, True)self.logView.setColumnHidden(ASSETID, True)self.logView.resizeColumnsToContents()self.logView.horizontalHeader().setStretchLastSection(True)logLabel = QLabel("&Logs")logLabel.setBuddy(self.logView)addAssetButton = QPushButton("&Add Asset")deleteAssetButton = QPushButton("&Delete Asset")addActionButton = QPushButton("Add A&ction")deleteActionButton = QPushButton("Delete Ac&tion")editActionsButton = QPushButton("&Edit Actions...")editCategoriesButton = QPushButton("Ed&it Categories...")quitButton = QPushButton("&Quit")for button in (addAssetButton, deleteAssetButton,addActionButton, deleteActionButton,editActionsButton, editCategoriesButton, quitButton):if MAC:button.setDefault(False)button.setAutoDefault(False)else:button.setFocusPolicy(Qt.NoFocus)dataLayout = QVBoxLayout()dataLayout.addWidget(assetLabel)dataLayout.addWidget(self.assetView, 1)dataLayout.addWidget(logLabel)dataLayout.addWidget(self.logView)buttonLayout = QVBoxLayout()buttonLayout.addWidget(addAssetButton)buttonLayout.addWidget(deleteAssetButton)buttonLayout.addWidget(addActionButton)buttonLayout.addWidget(deleteActionButton)buttonLayout.addWidget(editActionsButton)buttonLayout.addWidget(editCategoriesButton)buttonLayout.addStretch()buttonLayout.addWidget(quitButton)layout = QHBoxLayout()layout.addLayout(dataLayout, 1)layout.addLayout(buttonLayout)self.setLayout(layout)self.connect(self.assetView.selectionModel(),SIGNAL("currentRowChanged(QModelIndex,QModelIndex)"),self.assetChanged)self.connect(addAssetButton, SIGNAL("clicked()"),self.addAsset)self.connect(deleteAssetButton, SIGNAL("clicked()"),self.deleteAsset)self.connect(addActionButton, SIGNAL("clicked()"),self.addAction)self.connect(deleteActionButton, SIGNAL("clicked()"),self.deleteAction)self.connect(editActionsButton, SIGNAL("clicked()"),self.editActions)self.connect(editCategoriesButton, SIGNAL("clicked()"),self.editCategories)self.connect(quitButton, SIGNAL("clicked()"), self.done)self.assetChanged(self.assetView.currentIndex())self.setMinimumWidth(650)self.setWindowTitle("Asset Manager")def done(self, result=1):query = QSqlQuery()query.exec_("DELETE FROM logs WHERE logs.assetid NOT IN""(SELECT id FROM assets)")QDialog.done(self, 1)def assetChanged(self, index):if index.isValid():record = self.assetModel.record(index.row())id = record.value("id").toInt()[0]self.logModel.setFilter(QString("assetid = %1").arg(id))else:self.logModel.setFilter("assetid = -1")self.logModel.reset() # workaround for Qt <= 4.3.3/SQLite bugself.logModel.select()self.logView.horizontalHeader().setVisible(self.logModel.rowCount() > 0)if PYQT_VERSION_STR < "4.1.0":self.logView.setColumnHidden(ID, True)self.logView.setColumnHidden(ASSETID, True)def addAsset(self):row = self.assetView.currentIndex().row() \if self.assetView.currentIndex().isValid() else 0QSqlDatabase.database().transaction()self.assetModel.insertRow(row)index = self.assetModel.index(row, NAME)self.assetView.setCurrentIndex(index)assetid = 1query = QSqlQuery()query.exec_("SELECT MAX(id) FROM assets")if query.next():assetid = query.value(0).toInt()[0]query.prepare("INSERT INTO logs (assetid, date, actionid) ""VALUES (:assetid, :date, :actionid)")query.bindValue(":assetid", QVariant(assetid + 1))query.bindValue(":date", QVariant(QDate.currentDate()))query.bindValue(":actionid", QVariant(ACQUIRED))query.exec_()QSqlDatabase.database().commit()self.assetView.edit(index)def deleteAsset(self):index = self.assetView.currentIndex()if not index.isValid():returnQSqlDatabase.database().transaction()record = self.assetModel.record(index.row())assetid = record.value(ID).toInt()[0]logrecords = 1query = QSqlQuery(QString("SELECT COUNT(*) FROM logs ""WHERE assetid = %1").arg(assetid))if query.next():logrecords = query.value(0).toInt()[0]msg = QString("<font color=red>Delete</font><br><b>%1</b>""<br>from room %2") \.arg(record.value(NAME).toString()) \.arg(record.value(ROOM).toString())if logrecords > 1:msg += QString(", along with %1 log records") \.arg(logrecords)msg += "?"if QMessageBox.question(self, "Delete Asset", msg,QMessageBox.Yes|QMessageBox.No) == QMessageBox.No:QSqlDatabase.database().rollback()returnquery.exec_(QString("DELETE FROM logs WHERE assetid = %1") \.arg(assetid))self.assetModel.removeRow(index.row())self.assetModel.submitAll()QSqlDatabase.database().commit()self.assetChanged(self.assetView.currentIndex())def addAction(self):index = self.assetView.currentIndex()if not index.isValid():returnQSqlDatabase.database().transaction()record = self.assetModel.record(index.row())assetid = record.value(ID).toInt()[0]row = self.logModel.rowCount()self.logModel.insertRow(row)self.logModel.setData(self.logModel.index(row, ASSETID),QVariant(assetid))self.logModel.setData(self.logModel.index(row, DATE),QVariant(QDate.currentDate()))QSqlDatabase.database().commit()index = self.logModel.index(row, ACTIONID)self.logView.setCurrentIndex(index)self.logView.edit(index)def deleteAction(self):index = self.logView.currentIndex()if not index.isValid():returnrecord = self.logModel.record(index.row())action = record.value(ACTIONID).toString()if action == "Acquired":QMessageBox.information(self, "Delete Log","The 'Acquired' log record cannot be deleted.<br>""You could delete the entire asset instead.")returnwhen = unicode(record.value(DATE).toString())if QMessageBox.question(self, "Delete Log","Delete log<br>%s %s?" % (when, action),QMessageBox.Yes|QMessageBox.No) == QMessageBox.No:returnself.logModel.removeRow(index.row())self.logModel.submitAll()def editActions(self):form = ReferenceDataDlg("actions", "Action", self)form.exec_()def editCategories(self):form = ReferenceDataDlg("categories", "Category", self)form.exec_()def main():app = QApplication(sys.argv)filename = os.path.join(os.path.dirname(__file__), "assets.db")create = not QFile.exists(filename)db = QSqlDatabase.addDatabase("QSQLITE")db.setDatabaseName(filename)if not db.open():QMessageBox.warning(None, "Asset Manager",QString("Database Error: %1").arg(db.lastError().text()))sys.exit(1)splash = Noneif create:app.setOverrideCursor(QCursor(Qt.WaitCursor))splash = QLabel()pixmap = QPixmap(":/assetmanagersplash.png")splash.setPixmap(pixmap)splash.setMask(pixmap.createHeuristicMask())splash.setWindowFlags(Qt.SplashScreen)rect = app.desktop().availableGeometry()splash.move((rect.width() - pixmap.width()) / 2,(rect.height() - pixmap.height()) / 2)splash.show()app.processEvents()createFakeData()form = MainForm()form.show()if create:splash.close()app.processEvents()app.restoreOverrideCursor()app.exec_()del formdel dbmain()
pyqt4的一些相关资料整理相关推荐
- epoll相关资料整理
http://www.cppblog.com/converse/archive/2008/10/13/63928.html epoll相关资料整理 学习epoll有一段时间了,最近终于有一个服务器采用 ...
- 转:基于iOS上MDM技术相关资料整理及汇总
转自:http://www.mbaike.net/mdm/6.html 一.MDM相关知识: MDM (Mobile Device Management ),即移动设备管理.在21世纪的今天,数据是企 ...
- PRML:Pattern Recognition And Machine Learning 相关资料整理与下载
Pattern Recognition And Machine Learning 相关资料整理与下载 前言 一.PRML英文原文 二.PRML中文翻译版 三.PRML勘误与附加评论 四.读者整理的笔记 ...
- Scaleform相关资料整理
Scaleform相关资料整理 官方教程: http://udn.epicgames.com/Three/Scaleform.html 麻将桌的视频: http://gameware.autodesk ...
- Citrix 相关资料整理
转载请注明 http://blog.csdn.net/u011046042/article/details/72638345 思杰相关的资料整理: 官方网站 https://www.citrix.co ...
- 文本处理相关资料整理
github 搜索文本相似度 文本处理实践相关资料,包含文本特征提取(TF-IDF),文本分类,文本聚类,word2vec训练词向量及同义词词林中文词语相似度计算.文档自动摘要,信息抽取,情感分析与观 ...
- 无人机相关资料整理-备忘
近期一直在学习无人机相关基础知识以及平台搭建方面的知识,搜集了很多网站的相关信息,有一些比较有用的github.中英文资料.谈论区网址.还收藏了一些免费的课程,以及自己已购买的课程的链接.有些普及的教 ...
- 源码分析工具Joern的相关资料整理
随着对joern的了解,发现这个工具的潜能挺大的.但实际上手起来还是有点难度.这里列举一些对学习joern有帮助的相关资料博客. joern官方文档:https://docs.joern.io/ jo ...
- AS400相关资料整理(初学者)
AS400资料整理 1.如果你的权限足够的话,可以使用CRTLIB命令给自己建个库,如: CRTLIB LIB(MYLIB) TYPE(*TEST) TEXT('for test') 库建好之后,你可 ...
- 关于科研相关资料整理
目录 引言 相关资料 写作 阅读论文 鸡汤 科普 资源 总结 引言 再过几天,如果疫情不是太严重的话,研究生们估计就要陆陆续续地去学校了,有的是新生,有的是研二的,都要面临着一大堆科研工作.希望是我平 ...
最新文章
- 百度移动终端研发工程师笔试题
- Matlab中plot基本用法
- Android系统全貌 (转)
- SAP复合角色更改后扩展到派生节点
- windows的几个原则
- ACE中静态实例管理方式
- android icon 圆角半径,iOS和安卓APP启动图标的尺寸和圆角值详解
- 手把手教你dns服务器未响应导致无法上网怎么办
- Dell Kace K1000测试报告
- Tomcat 8.5 配置 SSL 证书 1
- C#中常用的分页存储过程
- 微信朋友圈八月十大谣言:洗澡先洗头会晕倒在浴室
- C++ 开发者怒了:这个无用的模块设计最终会害死 C++!
- 松翰单片机操作日记SN8F5721(同步串口)
- Debian Cacti(仙人掌)
- Go语言开发学习笔记(持续更新中)
- CF 783 F. Vlad and Unfinished Business
- android中的ssl_Android中的SSL固定
- MySQL学习笔记——基础语句
- Chromium命令行开关列表1