我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用PyQt5.QtCore.Qt.ElideRight()。
def createEditor(self, manager, property, parent): editor = self.d_ptr.createEditor(property, parent) editor.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon) editor.setMinimumContentsLength(1) editor.view().setTextElideMode(Qt.ElideRight) enumNames = manager.enumNames(property) editor.addItems(enumNames) enumIcons = manager.enumIcons(property) enumNamesCount = len(enumNames) for i in range(enumNamesCount): icon = enumIcons[i] if type(icon) is not QIcon: icon = QIcon() editor.setItemIcon(i, icon) editor.setCurrentIndex(manager.value(property)) editor.currentIndexChanged.connect(self.d_ptr.slotSetValue) editor.destroyed.connect(self.d_ptr.slotEditorDestroyed) return editor ### # \internal # Reimplemented from the QtAbstractEditorFactory class. ###
def on_table_selection_changed(self): min_row, max_row, start, end = self.ui.tableMessages.selection_range() if min_row == -1: self.ui.lEncodingValue.setText("-") # self.ui.lEncodingValue.setToolTip("") self.label_list_model.message = None return container = self.table_model.protocol message = container.messages[min_row] self.label_list_model.message = message decoder_name = message.decoder.name metrics = QFontMetrics(self.ui.lEncodingValue.font()) elidedName = metrics.elidedText(decoder_name, Qt.ElideRight, self.ui.lEncodingValue.width()) self.ui.lEncodingValue.setText(elidedName) self.ui.lEncodingValue.setToolTip(decoder_name) self.ui.cBoxModulations.blockSignals(True) self.ui.cBoxModulations.setCurrentIndex(message.modulator_index) self.show_modulation_info() self.ui.cBoxModulations.blockSignals(False)
def clipText(self, text: str, painter: QPainter) -> str: metrics = painter.fontMetrics() return metrics.elidedText(text, Qt.ElideRight, (self.parent.width() - 100 - 10))
def _set_building_text(self, labelCtrl, text): metrics = QtGui.QFontMetrics(labelCtrl.font()) elidedText = metrics.elidedText(text, Qt.ElideRight, labelCtrl.width()) labelCtrl.setText(elidedText)
def drawCellHeaderText(self, painter, rect): xMin, yMin, width, height = rect metrics = QFontMetrics(headerFont) minOffset = painter.pen().width() painter.setFont(headerFont) painter.setPen(cellMetricsTextColor) name = metrics.elidedText( self.glyph.name, Qt.ElideRight, width - 2) painter.drawText( 1, 0, width - 2, height - minOffset, Qt.TextSingleLine | Qt.AlignCenter | Qt.AlignBottom, name)