本文整理汇总了Python中PyQt5.QtWidgets.QTreeView.palette方法的典型用法代码示例。如果您正苦于以下问题:Python QTreeView.palette方法的具体用法?Python QTreeView.palette怎么用?Python QTreeView.palette使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QTreeView
的用法示例。
在下文中一共展示了QTreeView.palette方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FinderBox
# 需要导入模块: from PyQt5.QtWidgets import QTreeView [as 别名]
# 或者: from PyQt5.QtWidgets.QTreeView import palette [as 别名]
class FinderBox(QComboBox):
running = False
to_finish = 0
search_started = pyqtSignal()
search_finished = pyqtSignal()
def __init__(self, finders, iface, parent=None):
self.iface = iface
self.mapCanvas = iface.mapCanvas()
self.rubber = QgsRubberBand(self.mapCanvas)
self.rubber.setColor(QColor(255, 255, 50, 200))
self.rubber.setIcon(self.rubber.ICON_CIRCLE)
self.rubber.setIconSize(15)
self.rubber.setWidth(4)
self.rubber.setBrushStyle(Qt.NoBrush)
QComboBox.__init__(self, parent)
self.setEditable(True)
self.setInsertPolicy(QComboBox.InsertAtTop)
self.setMinimumHeight(27)
self.setSizePolicy(QSizePolicy.Expanding,
QSizePolicy.Fixed)
self.insertSeparator(0)
self.lineEdit().returnPressed.connect(self.search)
self.result_view = QTreeView()
self.result_view.setHeaderHidden(True)
self.result_view.setMinimumHeight(300)
self.result_view.activated.connect(self.itemActivated)
self.result_view.pressed.connect(self.itemPressed)
self.setView(self.result_view)
self.result_model = ResultModel(self)
self.setModel(self.result_model)
self.finders = finders
for finder in self.finders.values():
finder.result_found.connect(self.result_found)
finder.limit_reached.connect(self.limit_reached)
finder.finished.connect(self.finished)
self.clearButton = QPushButton(self)
self.clearButton.setIcon(QIcon(":/plugins/quickfinder/icons/draft.svg"))
self.clearButton.setText('')
self.clearButton.setFlat(True)
self.clearButton.setCursor(QCursor(Qt.ArrowCursor))
self.clearButton.setStyleSheet('border: 0px; padding: 0px;')
self.clearButton.clicked.connect(self.clear)
layout = QHBoxLayout(self)
self.setLayout(layout)
layout.addStretch()
layout.addWidget(self.clearButton)
layout.addSpacing(20)
button_size = self.clearButton.sizeHint()
# frameWidth = self.lineEdit().style().pixelMetric(QtGui.QStyle.PM_DefaultFrameWidth)
padding = button_size.width() # + frameWidth + 1
self.lineEdit().setStyleSheet('QLineEdit {padding-right: %dpx; }' % padding)
def __del__(self):
if self.rubber:
self.iface.mapCanvas().scene().removeItem(self.rubber)
del self.rubber
def clearSelection(self):
self.result_model.setSelected(None, self.result_view.palette())
self.rubber.reset()
def clear(self):
self.clearSelection()
self.result_model.clearResults()
self.lineEdit().setText('')
def keyPressEvent(self, event):
if event.key() == Qt.Key_Escape:
self.clearSelection()
QComboBox.keyPressEvent(self, event)
def search(self):
if self.running:
return
to_find = self.lineEdit().text()
if not to_find or to_find == '':
return
self.running = True
self.search_started.emit()
self.clearSelection()
self.result_model.clearResults()
self.result_model.truncateHistory(MySettings().value("historyLength"))
self.result_model.setLoading(True)
self.showPopup()
QCoreApplication.processEvents(QEventLoop.ExcludeUserInputEvents)
#.........这里部分代码省略.........