本文整理汇总了Python中PyQt4.QtSql.QSqlDatabase.connectionNames方法的典型用法代码示例。如果您正苦于以下问题:Python QSqlDatabase.connectionNames方法的具体用法?Python QSqlDatabase.connectionNames怎么用?Python QSqlDatabase.connectionNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtSql.QSqlDatabase
的用法示例。
在下文中一共展示了QSqlDatabase.connectionNames方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: refresh
# 需要导入模块: from PyQt4.QtSql import QSqlDatabase [as 别名]
# 或者: from PyQt4.QtSql.QSqlDatabase import connectionNames [as 别名]
def refresh(self):
"""
Public slot to refresh the connection tree.
"""
self.__connectionTree.clear()
self.emit(SIGNAL("cleared()"))
connectionNames = QSqlDatabase.connectionNames()
foundActiveDb = False
for name in connectionNames:
root = QTreeWidgetItem(self.__connectionTree)
db = QSqlDatabase.database(name, False)
root.setText(0, self.__dbCaption(db))
if name == self.__activeDb:
foundActiveDb = True
self.__setActive(root)
if db.isOpen():
tables = db.tables()
for table in tables:
itm = QTreeWidgetItem(root)
itm.setText(0, table)
if not foundActiveDb and connectionNames:
self.__activeDb = connectionNames[0]
self.__setActive(self.__connectionTree.topLevelItem(0))
示例2: __uiStartUp
# 需要导入模块: from PyQt4.QtSql import QSqlDatabase [as 别名]
# 或者: from PyQt4.QtSql.QSqlDatabase import connectionNames [as 别名]
def __uiStartUp(self):
"""
Private slot to do some actions after the UI has started and the main loop is up.
"""
for warning in self.__warnings:
KQMessageBox.warning(self,
self.trUtf8("SQL Browser startup problem"),
warning)
if QSqlDatabase.connectionNames().isEmpty():
self.__browser.addConnectionByDialog()
示例3: __setActive
# 需要导入模块: from PyQt4.QtSql import QSqlDatabase [as 别名]
# 或者: from PyQt4.QtSql.QSqlDatabase import connectionNames [as 别名]
def __setActive(self, itm):
"""
Private slot to set an item to active.
@param itm reference to the item to set as the active item (QTreeWidgetItem)
"""
for index in range(self.__connectionTree.topLevelItemCount()):
if self.__connectionTree.topLevelItem(index).font(0).bold():
self.__setBold(self.__connectionTree.topLevelItem(index), False)
if itm is None:
return
self.__setBold(itm, True)
self.__activeDb = QSqlDatabase.connectionNames()[
self.__connectionTree.indexOfTopLevelItem(itm)]