本文整理汇总了Python中PyQt5.QtWidgets.QTreeView.columnWidth方法的典型用法代码示例。如果您正苦于以下问题:Python QTreeView.columnWidth方法的具体用法?Python QTreeView.columnWidth怎么用?Python QTreeView.columnWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QTreeView
的用法示例。
在下文中一共展示了QTreeView.columnWidth方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _LocatorDialog
# 需要导入模块: from PyQt5.QtWidgets import QTreeView [as 别名]
# 或者: from PyQt5.QtWidgets.QTreeView import columnWidth [as 别名]
#.........这里部分代码省略.........
else:
self._applyCompleter(self._command, completer)
else:
self._applyCompleter(None, _HelpCompleter(self._commandClasses))
def _applyLoadingCompleter(self):
"""Set 'Loading...' message
"""
self._applyCompleter(None, StatusCompleter('<i>Loading...</i>'))
def onCompleterLoaded(self, command, completer):
"""The method called from _CompleterLoaderThread when the completer is ready
This code works in the GUI thread
"""
self._applyCompleter(command, completer)
def _applyCompleter(self, command, completer):
"""Apply completer. Called by _updateCompletion or by thread function when Completer is constructed
"""
self._loadingTimer.stop()
if command is not None:
command.onCompleterLoaded(completer)
if completer is None:
completer = _HelpCompleter([command])
if self._edit.cursorPosition() == len(self._edit.text()): # if cursor at the end of text
self._edit.setInlineCompletion(completer.inline())
self._model.setCompleter(completer)
if completer.columnCount() > 1:
self._table.resizeColumnToContents(0)
self._table.setColumnWidth(0, self._table.columnWidth(0) + 20) # 20 px spacing between columns
selItem = completer.autoSelectItem()
if selItem:
index = self._model.createIndex(selItem[0],
selItem[1])
self._table.setCurrentIndex(index)
def _onItemClicked(self, index):
"""Item in the TreeView has been clicked.
Open file, if user selected it
"""
if self._command is not None:
fullText = self._model.completer.getFullText(index.row())
if fullText is not None:
self._command.onItemClicked(fullText)
if self._tryExecCurrentCommand():
self.accept()
return
else:
self._edit.setText(self._command.lineEditText())
self._updateCurrentCommand()
self._edit.setFocus()
def _onEnterPressed(self):
"""User pressed Enter or clicked item. Execute command, if possible
"""
if self._table.currentIndex().isValid():
self._onItemClicked(self._table.currentIndex())
else:
self._tryExecCurrentCommand()