本文整理汇总了Python中PyQt5.QtWidgets.QTreeView.show方法的典型用法代码示例。如果您正苦于以下问题:Python QTreeView.show方法的具体用法?Python QTreeView.show怎么用?Python QTreeView.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QTreeView
的用法示例。
在下文中一共展示了QTreeView.show方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: len
# 需要导入模块: from PyQt5.QtWidgets import QTreeView [as 别名]
# 或者: from PyQt5.QtWidgets.QTreeView import show [as 别名]
parents.append(parents[-1].child(parents[-1].childCount() - 1))
indentations.append(position)
else:
while position < indentations[-1] and len(parents) > 0:
parents.pop()
indentations.pop()
# Append a new item to the current parent's list of children.
parents[-1].appendChild(TreeItem(columnData, parents[-1]))
number += 1
if __name__ == '__main__':
import sys
app = QApplication(sys.argv)
f = QFile(':/default.txt')
f.open(QIODevice.ReadOnly)
model = TreeModel(f.readAll())
f.close()
view = QTreeView()
view.setModel(model)
view.setWindowTitle("Simple Tree Model")
view.show()
sys.exit(app.exec_())
示例2: AddBookmarkDialog
# 需要导入模块: from PyQt5.QtWidgets import QTreeView [as 别名]
# 或者: from PyQt5.QtWidgets.QTreeView import show [as 别名]
class AddBookmarkDialog(QDialog, Ui_AddBookmarkDialog):
"""
Class implementing a dialog to add a bookmark or a bookmark folder.
"""
def __init__(self, parent=None, bookmarksManager=None):
"""
Constructor
@param parent reference to the parent widget (QWidget)
@param bookmarksManager reference to the bookmarks manager
object (BookmarksManager)
"""
super(AddBookmarkDialog, self).__init__(parent)
self.setupUi(self)
self.__bookmarksManager = bookmarksManager
self.__addedNode = None
self.__addFolder = False
if self.__bookmarksManager is None:
import Helpviewer.HelpWindow
self.__bookmarksManager = \
Helpviewer.HelpWindow.HelpWindow.bookmarksManager()
self.__proxyModel = AddBookmarkProxyModel(self)
model = self.__bookmarksManager.bookmarksModel()
self.__proxyModel.setSourceModel(model)
self.__treeView = QTreeView(self)
self.__treeView.setModel(self.__proxyModel)
self.__treeView.expandAll()
self.__treeView.header().setStretchLastSection(True)
self.__treeView.header().hide()
self.__treeView.setItemsExpandable(False)
self.__treeView.setRootIsDecorated(False)
self.__treeView.setIndentation(10)
self.__treeView.show()
self.locationCombo.setModel(self.__proxyModel)
self.locationCombo.setView(self.__treeView)
self.addressEdit.setInactiveText(self.tr("Url"))
self.nameEdit.setInactiveText(self.tr("Title"))
self.resize(self.sizeHint())
def setUrl(self, url):
"""
Public slot to set the URL of the new bookmark.
@param url URL of the bookmark (string)
"""
self.addressEdit.setText(url)
self.resize(self.sizeHint())
def url(self):
"""
Public method to get the URL of the bookmark.
@return URL of the bookmark (string)
"""
return self.addressEdit.text()
def setTitle(self, title):
"""
Public method to set the title of the new bookmark.
@param title title of the bookmark (string)
"""
self.nameEdit.setText(title)
def title(self):
"""
Public method to get the title of the bookmark.
@return title of the bookmark (string)
"""
return self.nameEdit.text()
def setDescription(self, description):
"""
Public method to set the description of the new bookmark.
@param description description of the bookamrk (string)
"""
self.descriptionEdit.setPlainText(description)
def description(self):
"""
Public method to get the description of the bookmark.
@return description of the bookamrk (string)
"""
return self.descriptionEdit.toPlainText()
def setCurrentIndex(self, idx):
"""
Public method to set the current index.
@param idx current index to be set (QModelIndex)
#.........这里部分代码省略.........
示例3: QFileSystemModel
# 需要导入模块: from PyQt5.QtWidgets import QTreeView [as 别名]
# 或者: from PyQt5.QtWidgets.QTreeView import show [as 别名]
try:
rootPath = parser.positionalArguments().pop(0)
except IndexError:
rootPath = None
model = QFileSystemModel()
model.setRootPath('')
if parser.isSet(dontUseCustomDirectoryIconsOption):
model.iconProvider().setOptions(
QFileIconProvider.DontUseCustomDirectoryIcons)
tree = QTreeView()
tree.setModel(model)
if rootPath is not None:
rootIndex = model.index(QDir.cleanPath(rootPath))
if rootIndex.isValid():
tree.setRootIndex(rootIndex)
# Demonstrating look and feel features.
tree.setAnimated(False)
tree.setIndentation(20)
tree.setSortingEnabled(True)
availableSize = QApplication.desktop().availableGeometry(tree).size()
tree.resize(availableSize / 2)
tree.setColumnWidth(0, tree.width() / 3)
tree.setWindowTitle("Dir View")
tree.show()
sys.exit(app.exec_())
示例4: QStandardItem
# 需要导入模块: from PyQt5.QtWidgets import QTreeView [as 别名]
# 或者: from PyQt5.QtWidgets.QTreeView import show [as 别名]
# Defining a couple of items
americaItem = QStandardItem("America")
canadaItem = QStandardItem("Canada")
europeItem = QStandardItem("Europe")
franceItem = QStandardItem("France")
brittanyItem = QStandardItem("Brittany")
# Building up the hierarchy
rootItem.appendRow(americaItem)
rootItem.appendRow(europeItem)
americaItem.appendRow(canadaItem)
europeItem.appendRow(franceItem)
franceItem.appendRow(brittanyItem)
tree_view.setModel(model)
# Bind selection to the print_selection function (must be after the model setup)
selection_model = tree_view.selectionModel()
selection_model.selectionChanged.connect(print_selection)
tree_view.expandAll() # expand all (this is not the case by default)
tree_view.show()
# The mainloop of the application. The event handling starts from this point.
# The exec_() method has an underscore. It is because the exec is a Python keyword. And thus, exec_() was used instead.
exit_code = app.exec_()
# The sys.exit() method ensures a clean exit.
# The environment will be informed, how the application ended.
sys.exit(exit_code)
示例5: QApplication
# 需要导入模块: from PyQt5.QtWidgets import QTreeView [as 别名]
# 或者: from PyQt5.QtWidgets.QTreeView import show [as 别名]
self.insertRow(0)
self.setData(self.index(0, self.FROM), mail_from)
self.setData(self.index(0, self.SUBJECT), subject)
self.setData(self.index(0, self.DATE), date)
if __name__ == '__main__':
app = QApplication(sys.argv)
dataView = QTreeView()
dataView.setRootIsDecorated(False)
dataView.setAlternatingRowColors(True)
model = MyModel()
# Add data
model.addMail('[email protected]', 'Your Github Donation', '03/25/2017 02:05 PM')
model.addMail('[email protected]', 'Github Projects', '02/02/2017 03:05 PM')
model.addMail('[email protected]', 'Your Phone Bill', '01/01/2017 04:05 PM')
dataView.setModel(model)
dataView.show()
# The mainloop of the application. The event handling starts from this point.
# The exec_() method has an underscore. It is because the exec is a Python keyword. And thus, exec_() was used instead.
exit_code = app.exec_()
# The sys.exit() method ensures a clean exit.
# The environment will be informed, how the application ended.
sys.exit(exit_code)
开发者ID:jeremiedecock,项目名称:snippets,代码行数:32,代码来源:widget_QTreeView_multiple_columns_mail_insert_example.py
示例6: QModelIndex
# 需要导入模块: from PyQt5.QtWidgets import QTreeView [as 别名]
# 或者: from PyQt5.QtWidgets.QTreeView import show [as 别名]
if childItem:
return self.createIndex(row, column, childItem)
else:
return QModelIndex()
def parent(self, index):
if not index.isValid():
return QModelIndex()
childItem = index.internalPointer()
if not childItem:
return QModelIndex()
parentItem = childItem.parent()
if parentItem == self.rootItem:
return QModelIndex()
return self.createIndex(parentItem.row(), 0, parentItem)
if __name__ == "__main__" :
# http://blog.mathieu-leplatre.info/filesystem-watch-with-pyqt4.html
import sys
app = QApplication(sys.argv)
TreeView = QTreeView()
TreeModel = NodeTree(TreeView, [['A',['a',1]],['C','D'],['E','F']])
TreeView.setModel(TreeModel)
TreeView.show()
app.exec_()