本文整理汇总了C++中QTextEdit::setPlainText方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextEdit::setPlainText方法的具体用法?C++ QTextEdit::setPlainText怎么用?C++ QTextEdit::setPlainText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextEdit
的用法示例。
在下文中一共展示了QTextEdit::setPlainText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QDialog
AboutDialog::AboutDialog(QWidget *p, AboutDialogOptions options) : QDialog(p) {
setWindowTitle(tr("About Murmur"));
setMinimumSize(QSize(400, 300));
QTabWidget *qtwTab = new QTabWidget(this);
QVBoxLayout *vblMain = new QVBoxLayout(this);
QTextEdit *qteLicense = new QTextEdit(qtwTab);
qteLicense->setReadOnly(true);
qteLicense->setPlainText(License::license());
QTextEdit *qteAuthors = new QTextEdit(qtwTab);
qteAuthors->setReadOnly(true);
qteAuthors->setPlainText(License::authors());
QTextBrowser *qtb3rdPartyLicense = new QTextBrowser(qtwTab);
qtb3rdPartyLicense->setReadOnly(true);
qtb3rdPartyLicense->setOpenExternalLinks(true);
QList<LicenseInfo> thirdPartyLicenses = License::thirdPartyLicenses();
foreach(LicenseInfo li, thirdPartyLicenses) {
qtb3rdPartyLicense->append(QString::fromLatin1("<h3>%1 (<a href=\"%2\">%2</a>)</h3><pre>%3</pre>")
.arg(Qt::escape(li.name))
.arg(Qt::escape(li.url))
.arg(Qt::escape(li.license)));
}
示例2: createLicensePanel
QWidget* AboutBox::createLicensePanel()
{
// Create a label to display readme.txt
QTextEdit* label = new QTextEdit();
label->setReadOnly(true);
QString fileName(QString::fromUtf8(m_gleInterface->getManualLocation().c_str()));
fileName.resize(fileName.lastIndexOf(QDir::separator()));
fileName += QDir::separator();
fileName += tr("LICENSE.txt");
GLEInterface* iface = GLEGetInterfacePointer();
std::string licenseFileTxt;
bool res = iface->readFileOrGZIPTxt(fileName.toUtf8().constData(), &licenseFileTxt);
if (res) {
QFont font;
// Set the font to be fixed pitch
font.setFixedPitch(true);
font.setFamily("Courier");
font.setStretch(QFont::Condensed);
label->setLineWrapMode(QTextEdit::NoWrap);
label->setFont(font);
label->setTextColor(Qt::black);
// Get the text and put it in the label
label->setPlainText(licenseFileTxt.c_str());
QFontMetrics fm(font);
m_minWidth = fm.width("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
} else {
label->setPlainText(tr("File not found: '%1'").arg(fileName));
}
return label;
}
示例3: onTextChanged
void MainWindow::onTextChanged()
{
// force the length to always be 1
QTextEdit *textEdit = reinterpret_cast<QTextEdit*>(sender());
if (textEdit->toPlainText().length() > 1)
textEdit->setPlainText(textEdit->toPlainText().at(0));
}
示例4: editTextClicked
void EditStyle::editTextClicked(int id)
{
QTextEdit* e = 0;
switch (id) {
case 0: e = evenHeaderL; break;
case 1: e = evenHeaderC; break;
case 2: e = evenHeaderR; break;
case 3: e = oddHeaderL; break;
case 4: e = oddHeaderC; break;
case 5: e = oddHeaderR; break;
case 6: e = evenFooterL; break;
case 7: e = evenFooterC; break;
case 8: e = evenFooterR; break;
case 9: e = oddFooterL; break;
case 10: e = oddFooterC; break;
case 11: e = oddFooterR; break;
}
if (e == 0)
return;
bool styled = id < 6 ? headerStyled->isChecked() : footerStyled->isChecked();
if (styled)
e->setPlainText(editPlainText(e->toPlainText(), tr("Edit Plain Text")));
else
e->setHtml(editHtml(e->toHtml(), tr("Edit HTML Text")));
}
示例5: displayFile
void AboutDialog::displayFile(const QString &fileName, const QString &title)
{
QDialog *dialog = new QDialog(this);
QLayout *layout = new QVBoxLayout(dialog);
QTextEdit *textEdit = new QTextEdit(dialog);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, dialog);
textEdit->setStyleSheet(QLatin1String("font-family: monospace"));
QFile file(fileName);
if (file.open(QIODevice::ReadOnly)) {
QString text = QTextStream(&file).readAll();
textEdit->setPlainText(text);
}
textEdit->setReadOnly(true);
connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(close()));
buttonBox->setCenterButtons(true);
layout->addWidget(textEdit);
layout->addWidget(buttonBox);
layout->setMargin(6);
dialog->setLayout(layout);
dialog->setWindowTitle(title);
dialog->setWindowFlags(Qt::Sheet);
dialog->resize(600, 350);
dialog->exec();
}
示例6: on_listWidgetFormats_currentItemChanged
void ClipboardDialog::on_listWidgetFormats_currentItemChanged(
QListWidgetItem *current, QListWidgetItem *)
{
ui->actionRemove_Format->setEnabled(current != NULL);
QTextEdit *edit = ui->textEditContent;
QString mime = current ? current->text() : QString();
edit->clear();
const QByteArray bytes = m_data.value(mime).toByteArray();
if ( mime.startsWith(QString("image")) ) {
edit->document()->addResource( QTextDocument::ImageResource,
QUrl("data://1"), bytes );
edit->setHtml( QString("<img src=\"data://1\" />") );
} else {
QTextCodec *codec = QTextCodec::codecForName("utf-8");
if (mime == QLatin1String("text/html"))
codec = QTextCodec::codecForHtml(bytes, codec);
else
codec = QTextCodec::codecForUtfText(bytes, codec);
edit->setPlainText( codec ? codec->toUnicode(bytes) : QString() );
}
ui->labelProperties->setText(
tr("<strong> mime:</strong> %1 <strong>size:</strong> %2 bytes")
.arg(escapeHtml(mime))
.arg(QString::number(bytes.size())));
}
示例7: file
LicenseDialog::LicenseDialog(QWidget *parent)
:QDialog(parent, Qt::WindowCloseButtonHint)
{
QFile file(QLatin1String(":/traceshark/LICENSE"));
if (!file.open(QIODevice::ReadOnly))
qDebug() << "Warning, could not read license!\n";
QTextStream textStream(&file);
QString text = textStream.readAll();
QTextEdit *textEdit = new QTextEdit();
textEdit->setAcceptRichText(false);
textEdit->setPlainText(text);
textEdit->setReadOnly(true);
textEdit->setLineWrapMode(QTextEdit::NoWrap);
QVBoxLayout *vlayout = new QVBoxLayout;
setLayout(vlayout);
vlayout->addWidget(textEdit);
QHBoxLayout *hlayout = new QHBoxLayout;
vlayout->addLayout(hlayout);
hlayout->addStretch();
QPushButton *button = new QPushButton(tr("OK"));
hlayout->addWidget(button);
hlayout->addStretch();
setModal(true);
updateSize();
hide();
tsconnect(button, clicked(), this, hide());
}
示例8: typeWriterFontChanged
void ConsoleImpl::typeWriterFontChanged() {
QTextEdit* te = textEditOutput;
te->setFont(QGit::TYPE_WRITER_FONT);
te->setPlainText(te->toPlainText());
te->moveCursor(QTextCursor::End);
}
示例9: wrapDescription
// Extract the wrapped text from a text edit, which performs
// the wrapping only optically.
void SubmitEditorWidget::wrapDescription()
{
if (!lineWrap())
return;
const QChar newLine = QLatin1Char('\n');
QTextEdit e;
e.setVisible(false);
e.setMinimumWidth(1000);
e.setFontPointSize(1.0);
e.setLineWrapColumnOrWidth(d->m_ui.description->lineWrapColumnOrWidth());
e.setLineWrapMode(d->m_ui.description->lineWrapMode());
e.setWordWrapMode(d->m_ui.description->wordWrapMode());
e.setPlainText(d->m_description);
d->m_description.clear();
QTextCursor cursor(e.document());
cursor.movePosition(QTextCursor::Start);
while (!cursor.atEnd()) {
const QString block = cursor.block().text();
if (block.startsWith(QLatin1Char('\t'))) { // Don't wrap
d->m_description += block + newLine;
cursor.movePosition(QTextCursor::EndOfBlock);
} else {
forever {
cursor.select(QTextCursor::LineUnderCursor);
d->m_description += cursor.selectedText();
d->m_description += newLine;
cursor.clearSelection();
if (cursor.atBlockEnd())
break;
cursor.movePosition(QTextCursor::NextCharacter);
}
}
cursor.movePosition(QTextCursor::NextBlock);
}
}
示例10: setEditorData
void ThumbDelegate::setEditorData( QWidget * editor, const QModelIndex & index ) const
{
if( index.column() == BachAssetItem::Column_Info ) {
QTextEdit * textEdit = static_cast<QTextEdit*>(editor);
QVariant displayData = index.model()->data(index, Qt::DisplayRole);
textEdit->setPlainText(displayData.toString());
}
}
示例11: slotSourceDownloaded
void MainWindow::slotSourceDownloaded()
{
QNetworkReply* reply = qobject_cast<QNetworkReply*>(const_cast<QObject*>(sender()));
QTextEdit* textEdit = new QTextEdit(NULL);
textEdit->setAttribute(Qt::WA_DeleteOnClose);
textEdit->show();
textEdit->setPlainText(reply->readAll());
}
示例12: setEditorData
void ItemWidget::setEditorData(QWidget *editor, const QModelIndex &index) const
{
QTextEdit *textEdit = qobject_cast<QTextEdit *>(editor);
if (textEdit != NULL) {
const QString text = index.data(Qt::EditRole).toString();
textEdit->setPlainText(text);
textEdit->selectAll();
}
}
示例13: setEditorData
void CColumnDelegate::setEditorData(QWidget *editor_widg, const QModelIndex &index) const
{
if (columnindex==ContentIndex)
{
QTextEdit* editor = qobject_cast<QTextEdit*>(editor_widg);
editor->setPlainText(index.data().toString());
}
else
return QStyledItemDelegate::setEditorData(editor_widg,index);
}
示例14: newTab
void Widget::newTab()
{
QString title = tr("new text field") + QString::number(++countTab);
QTextEdit *text = new QTextEdit();
text->setPlainText(tr("Hello World !!"));
//connect(text, SIGNAL(textChanged()), this, SLOT(textChecker()));
m_Tab->addTab(text, title);
m_Tab->setCurrentIndex(m_Tab->count() - 1);
printf("debug\n");
}
示例15: SetValue
void ItemHandlerMultiLine::SetValue (QWidget *widget, const QVariant& value) const
{
QTextEdit *edit = qobject_cast<QTextEdit*> (widget);
if (!edit)
{
qWarning () << Q_FUNC_INFO
<< "not a QTextEdit"
<< widget;
return;
}
edit->setPlainText (value.toStringList ().join ("\n"));
}