我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用PyQt5.QtCore.Qt.PlainText()。
def dropEvent(self, event): mimeData = event.mimeData() if mimeData.hasImage(): self.setPixmap(QPixmap(mimeData.imageData())) elif mimeData.hasHtml(): self.setText(mimeData.html()) self.setTextFormat(Qt.RichText) elif mimeData.hasText(): self.setText(mimeData.text()) self.setTextFormat(Qt.PlainText) elif mimeData.hasUrls(): self.setText("\n".join([url.path() for url in mimeData.urls()])) else: self.setText("Cannot display data") self.setBackgroundRole(QPalette.Dark) event.acceptProposedAction()
def slotUpdate(self): for item in self.m_recreateQueue: par = item.parent w = 0 l = 0 oldRow = -1 if (not par): w = self.q_ptr l = self.m_mainLayout oldRow = self.m_children.indexOf(item) else: w = par.groupBox l = par.layout oldRow = par.children.indexOf(item) if (self.hasHeader(par)): oldRow += 2 if (item.widget): item.widget.setParent(w) elif (item.widgetLabel): item.widgetLabel.setParent(w) else: item.widgetLabel = QLabel(w) item.widgetLabel.setSizePolicy(QSizePolicy(QSizePolicy.Ignored, QSizePolicy.Fixed)) item.widgetLabel.setTextFormat(Qt.PlainText) span = 1 if (item.widget): l.addWidget(item.widget, oldRow, 1, 1, 1) elif (item.widgetLabel): l.addWidget(item.widgetLabel, oldRow, 1, 1, 1) else: span = 2 item.label = QLabel(w) item.label.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)) l.addWidget(item.label, oldRow, 0, 1, span) self.updateItem(item) self.m_recreateQueue.clear()