本文整理汇总了Python中PyQt5.QtWidgets.QTreeView方法的典型用法代码示例。如果您正苦于以下问题:Python QtWidgets.QTreeView方法的具体用法?Python QtWidgets.QTreeView怎么用?Python QtWidgets.QTreeView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets
的用法示例。
在下文中一共展示了QtWidgets.QTreeView方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QTreeView [as 别名]
def __init__(self, parent):
self.parent = parent
self.parentTab = self.parent.parent
self.searchThread = BackGroundTextSearch()
self.searchOptionsLayout = QtWidgets.QHBoxLayout()
self.searchTabLayout = QtWidgets.QVBoxLayout()
self.searchTimer = QtCore.QTimer(self.parent)
self.searchLineEdit = QtWidgets.QLineEdit(self.parent)
self.searchBookButton = QtWidgets.QToolButton(self.parent)
self.caseSensitiveSearchButton = QtWidgets.QToolButton(self.parent)
self.matchWholeWordButton = QtWidgets.QToolButton(self.parent)
self.searchResultsTreeView = QtWidgets.QTreeView(self.parent)
self._translate = QtCore.QCoreApplication.translate
self.search_string = self._translate('SideDock', 'Search')
self.search_book_string = self._translate('SideDock', 'Search entire book')
self.case_sensitive_string = self._translate('SideDock', 'Match case')
self.match_word_string = self._translate('SideDock', 'Match word')
self.create_widgets()
示例2: populate_combo_box
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QTreeView [as 别名]
def populate_combo_box(self):
def set_toc_position(tocTree):
currentIndex = tocTree.currentIndex()
required_position = currentIndex.data(QtCore.Qt.UserRole)
self.return_focus()
self.parent.set_content(required_position, True, True)
# Create the Combobox / Treeview combination
tocTree = QtWidgets.QTreeView()
self.tocComboBox.setView(tocTree)
self.tocComboBox.setModel(self.parent.tocModel)
tocTree.setRootIsDecorated(False)
tocTree.setItemsExpandable(False)
tocTree.expandAll()
# Set the position of the QComboBox
self.parent.set_tocBox_index(None, self.tocComboBox)
# Make clicking do something
self.tocComboBox.currentIndexChanged.connect(
lambda: set_toc_position(tocTree))
示例3: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QTreeView [as 别名]
def __init__(self):
super(QtWidgets.QTreeView, self).__init__()
# self.__typeWidgets = {}
# self.__typeWrappers = {}
model = QtGui.QStandardItemModel(0, 1)
model.setHorizontalHeaderLabels(
["Name", "Value", "Unit", "Class", "Description"]
)
self.rootNode = model.invisibleRootItem()
self.setModel(model)
self.setColumnWidth(0, 150)
self.setAlternatingRowColors(True)
示例4: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QTreeView [as 别名]
def __init__(self, widget):
"""
Initialize the ontology explorer view.
:type widget: OntologyExplorerWidget
"""
super().__init__(widget)
self.setContextMenuPolicy(QtCore.Qt.PreventContextMenu)
self.setEditTriggers(QtWidgets.QTreeView.NoEditTriggers)
self.setFont(Font('Roboto', 12))
self.setFocusPolicy(QtCore.Qt.NoFocus)
self.setHeaderHidden(True)
self.setHorizontalScrollMode(QtWidgets.QTreeView.ScrollPerPixel)
self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
self.setSelectionMode(QtWidgets.QTreeView.SingleSelection)
self.setSortingEnabled(True)
self.setWordWrap(True)
#############################################
# PROPERTIES
#################################
示例5: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QTreeView [as 别名]
def __init__(self, widget):
"""
Initialize the project explorer view.
:type widget: ProjectExplorerWidget
"""
super().__init__(widget)
self.setContextMenuPolicy(QtCore.Qt.PreventContextMenu)
self.setEditTriggers(QtWidgets.QTreeView.NoEditTriggers)
self.setFocusPolicy(QtCore.Qt.NoFocus)
self.setHeaderHidden(True)
self.setHorizontalScrollMode(QtWidgets.QTreeView.ScrollPerPixel)
self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
self.setSelectionMode(QtWidgets.QTreeView.SingleSelection)
self.setSortingEnabled(True)
self.setWordWrap(True)
#############################################
# PROPERTIES
#################################
示例6: setupUi
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QTreeView [as 别名]
def setupUi(self, GDriveDialog):
GDriveDialog.setObjectName("GDriveDialog")
GDriveDialog.resize(528, 348)
self.gridLayout = QtWidgets.QGridLayout(GDriveDialog)
self.gridLayout.setObjectName("gridLayout")
self.verticalLayout = QtWidgets.QVBoxLayout()
self.verticalLayout.setObjectName("verticalLayout")
self.tree = QtWidgets.QTreeView(GDriveDialog)
self.tree.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
self.tree.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
self.tree.setObjectName("tree")
self.tree.header().setVisible(False)
self.verticalLayout.addWidget(self.tree)
self.buttonBox = QtWidgets.QDialogButtonBox(GDriveDialog)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Open)
self.buttonBox.setObjectName("buttonBox")
self.verticalLayout.addWidget(self.buttonBox)
self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1)
self.retranslateUi(GDriveDialog)
self.buttonBox.accepted.connect(GDriveDialog.accept)
self.buttonBox.rejected.connect(GDriveDialog.reject)
QtCore.QMetaObject.connectSlotsByName(GDriveDialog)
示例7: generate_combo_box_action
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QTreeView [as 别名]
def generate_combo_box_action(self, contextMenu):
contextMenu.addSeparator()
def set_toc_position(tocTree):
currentIndex = tocTree.currentIndex()
required_position = currentIndex.data(QtCore.Qt.UserRole)
self.pw.parent.set_content(required_position, True, True)
# Create the Combobox / Treeview combination
tocComboBox = QtWidgets.QComboBox()
tocTree = QtWidgets.QTreeView()
tocComboBox.setView(tocTree)
tocComboBox.setModel(self.pw.parent.tocModel)
tocTree.setRootIsDecorated(False)
tocTree.setItemsExpandable(False)
tocTree.expandAll()
# Set the position of the QComboBox
self.pw.parent.set_tocBox_index(None, tocComboBox)
# Make clicking do something
tocComboBox.currentIndexChanged.connect(
lambda: set_toc_position(tocTree))
comboboxAction = QtWidgets.QWidgetAction(self.pw)
comboboxAction.setDefaultWidget(tocComboBox)
contextMenu.addAction(comboboxAction)
示例8: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QTreeView [as 别名]
def __init__(self):
super(QTreeView, self).__init__()
示例9: selectionChanged
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QTreeView [as 别名]
def selectionChanged(self, *args, **kwds):
self.customSelectionChanged.emit(*args, **kwds)
super(QTreeView, self).selectionChanged(*args, **kwds)
示例10: widgetTree
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QTreeView [as 别名]
def widgetTree(self):
"""Create selected objects tree.
"""
tree = QTreeView()
tree.header().setHidden(True)
tree.setDragEnabled(True)
tree.setSelectionMode(QAbstractItemView.ExtendedSelection)
tree.setDefaultDropAction(QtCore.Qt.MoveAction)
tree.setDragDropMode(QAbstractItemView.InternalMove)
tree.setAcceptDrops(True)
tree.setDropIndicatorShown(True)
return tree
示例11: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QTreeView [as 别名]
def __init__(self, model, parent=None):
super().__init__(parent)
self.setWindowTitle('CHATIMUS Settings')
self.setStyleSheet('background: black; color: white;')
ok_button = QtWidgets.QPushButton('Ok')
ok_button.setDefault(True)
cancel_button = QtWidgets.QPushButton('Cancel')
apply_button = QtWidgets.QPushButton('Apply')
layout = QtWidgets.QVBoxLayout()
tree_view = QtWidgets.QTreeView()
# tree_view.setHeaderHidden(True)
tree_view.setModel(model)
tree_view.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectItems)
tree_view.setUniformRowHeights(True)
tree_view.setAnimated(False)
tree_view.setAllColumnsShowFocus(True)
tree_view.resizeColumnToContents(0)
layout.addWidget(tree_view)
horizontal_button_widget = QtWidgets.QWidget()
horizontal_layout = QtWidgets.QHBoxLayout()
horizontal_layout.addWidget(ok_button)
horizontal_layout.addWidget(cancel_button)
horizontal_layout.addWidget(apply_button)
horizontal_button_widget.setLayout(horizontal_layout)
layout.addWidget(horizontal_button_widget)
ok_button.clicked.connect(self.done)
cancel_button.clicked.connect(self.reject)
# TODO: add in apply button connection
self.setLayout(layout)
示例12: get_view_horizontal_header
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QTreeView [as 别名]
def get_view_horizontal_header(self):
if isinstance(self.view, QTableView):
return self.view.horizontalHeader()
elif isinstance(self.view, QTreeView):
return self.view.header()
else:
raise Exception('Unsupported view type: %s', str(type(self.view)))
示例13: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QTreeView [as 别名]
def __init__(self):
super().__init__()
self.setWindowTitle("Treeview for nested dict/list")
self.setGeometry(300, 300, 600, 800)
tree_view = QTreeView()
tree_view.setModel(TreeModel(data))
self.setCentralWidget(tree_view)
示例14: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QTreeView [as 别名]
def __init__(self, *args):
QtWidgets.QFileDialog.__init__(self, *args)
self.setOption(self.DontUseNativeDialog, False)
self.setFileMode(self.ExistingFiles)
btns = self.findChildren(QtWidgets.QPushButton)
self.openBtn = [x for x in btns if 'open' in str(x.text()).lower()][0]
self.openBtn.clicked.disconnect()
self.openBtn.clicked.connect(self.openClicked)
self.tree = self.findChild(QtWidgets.QTreeView)
示例15: focusOutEvent
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QTreeView [as 别名]
def focusOutEvent(self, event):
# If we un focus from the QTreeView then we make the highlighted item color white
self.palette.setColor(
QPalette.Highlight, QColor(editor["UnfocusedHighlightColor"]).lighter()
)
# self.clearSelection() Uncomment this if you want to remove all highlighting when unfocused
self.app.setPalette(self.palette)