本文整理汇总了C++中QTextEdit::toPlainText方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextEdit::toPlainText方法的具体用法?C++ QTextEdit::toPlainText怎么用?C++ QTextEdit::toPlainText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextEdit
的用法示例。
在下文中一共展示了QTextEdit::toPlainText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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));
}
示例2: tryEnableInjectionButtons
bool MainWindow::tryEnableInjectionButtons()
{
QTextEdit* savePathTextField = this->findChild<QTextEdit*>("SavePathTextEdit");
QString pathToSave = savePathTextField->toPlainText();
QFile saveFile(pathToSave);
if(!saveFile.exists() || !pathToSave.endsWith(".sfs"))
{
setInjectionEnabled(false);
return false;
}
QTextEdit* injectPathTextField = this->findChild<QTextEdit*>("fileToInjectTextEdit");
QString pathToInjectFrom = injectPathTextField->toPlainText();
QFile injectFile(pathToInjectFrom);
if(!injectFile.exists() || !pathToInjectFrom.endsWith(".sfs"))
{
setInjectionEnabled(false);
return false;
}
setInjectionEnabled(true);
return true;
}
示例3: setModelData
void WrapTextDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const
{
qWarning( "WrapTextDelegate::setModelData called" );
QTextEdit * textEdit = static_cast<QTextEdit*>(editor);
if ( index.column() == BachAssetItem::Column_Info ) {
BachAsset ba = ((RecordSuperModel*)model)->getRecord(index);
ba.setTags( textEdit->toPlainText() );
ba.commit();
model->setData(index, QVariant(textEdit->toPlainText()), Qt::EditRole );
}
}
示例4: sendConvoMessage
/**
* Gets the conversation corresponding to the
* currently selected tab, and sends whatever's in its
* message text-box to all participants of the conversation.
* @brief MainWindow::sendConvoMessage
*/
void MainWindow::sendConvoMessage()
{
Conversation *cdata = convos->at(ui->tabgrpConversations->currentIndex()-1);
QTextEdit* txtMsg = ui->tabgrpConversations->currentWidget()->findChild<QTextEdit*>(CONVO_TAB_MSG_ID);
QTextEdit* txtConv = ui->tabgrpConversations->currentWidget()->findChild<QTextEdit*>(CONVO_TAB_TXT_ID);
if(txtMsg->toPlainText().length() > 0)
{
controller->sendConvoMessage(cdata, txtMsg->toPlainText());
addTextToConvo(txtConv, controller->myName() + "|" + txtMsg->toPlainText());
txtMsg->clear();
}
}
示例5: updateShader
void BasicSurface::updateShader()
{
QTextEdit* text = window()->findChild<QTextEdit*>("fragText");
QString frag = text->toPlainText();
text = window()->findChild<QTextEdit*>("vertText");
QString vert = text->toPlainText();
program.removeAllShaders();
program.addShaderFromSourceCode(QOpenGLShader::Vertex, vert);
program.addShaderFromSourceCode(QOpenGLShader::Fragment, frag);
program.link();
program.bind();
update();
}
示例6: save
void DesignerFields::save( DesignerFields::Storage *storage )
{
QMap<QString, QWidget*>::Iterator it;
for ( it = mWidgets.begin(); it != mWidgets.end(); ++it ) {
QString value;
if ( it.value()->inherits( "QLineEdit" ) ) {
QLineEdit *wdg = static_cast<QLineEdit*>( it.value() );
value = wdg->text();
} else if ( it.value()->inherits( "QSpinBox" ) ) {
QSpinBox *wdg = static_cast<QSpinBox*>( it.value() );
value = QString::number( wdg->value() );
} else if ( it.value()->inherits( "QCheckBox" ) ) {
QCheckBox *wdg = static_cast<QCheckBox*>( it.value() );
value = ( wdg->isChecked() ? "true" : "false" );
} else if ( it.value()->inherits( "QDateTimeEdit" ) ) {
Q3DateTimeEdit *wdg = static_cast<Q3DateTimeEdit*>( it.value() );
value = wdg->dateTime().toString( Qt::ISODate );
} else if ( it.value()->inherits( "KDateTimeWidget" ) ) {
KDateTimeWidget *wdg = static_cast<KDateTimeWidget*>( it.value() );
value = wdg->dateTime().toString( Qt::ISODate );
} else if ( it.value()->inherits( "KDatePicker" ) ) {
KDatePicker *wdg = static_cast<KDatePicker*>( it.value() );
value = wdg->date().toString( Qt::ISODate );
} else if ( it.value()->inherits( "QComboBox" ) ) {
QComboBox *wdg = static_cast<QComboBox*>( it.value() );
value = wdg->currentText();
} else if ( it.value()->inherits( "QTextEdit" ) ) {
QTextEdit *wdg = static_cast<QTextEdit*>( it.value() );
value = wdg->toPlainText();
}
storage->write( it.key(), value );
}
}
示例7: slotSetFormData
void PageItem::slotSetFormData()
{
QTextEdit *textEdit = qobject_cast<QTextEdit*>(sender());
if (textEdit) // textEdit == 0 if the above cast fails
{
slotSetFormData(textEdit->toPlainText());
return;
}
QListWidget *listWidget = qobject_cast<QListWidget*>(sender());
if (listWidget)
{
QList<int> choices;
for (int i = 0; i < listWidget->count(); ++i)
{
if (listWidget->item(i)->isSelected())
choices << i;
}
QString objectName = sender()->objectName();
if (!objectName.startsWith(QLatin1String("PageItem::formField")))
return;
int which = objectName.remove(QLatin1String("PageItem::formField")).toInt();
Poppler::FormFieldChoice *formField = static_cast<Poppler::FormFieldChoice*>(m_formFields.at(which).field);
formField->setCurrentChoices(choices);
return;
}
}
示例8: GWEN_Widget_GetText
const char *getCharProperty(GWEN_DIALOG_PROPERTY prop,
int index,
const char *defaultValue) {
QTextEdit *qw;
QString str;
qw=(QTextEdit*) GWEN_Widget_GetImplData(_widget, QT4_DIALOG_WIDGET_REAL);
assert(qw);
switch(prop) {
case GWEN_DialogProperty_Value:
str=qw->toPlainText();
if (str.isEmpty())
return defaultValue;
else {
GWEN_Widget_SetText(_widget, QT4_DIALOG_STRING_TITLE, str.toUtf8());
return GWEN_Widget_GetText(_widget, QT4_DIALOG_STRING_TITLE);
}
break;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(_widget)));
return defaultValue;
};
示例9: addIncomingChatMsg
/**
* We get a new Message from a chat participant
*
* - Ignore Messages from muted chat participants
*/
void ChatLobbyDialog::addIncomingChatMsg(const ChatInfo& info)
{
QDateTime sendTime = QDateTime::fromTime_t(info.sendTime);
QDateTime recvTime = QDateTime::fromTime_t(info.recvTime);
QString message = QString::fromStdWString(info.msg);
QString name = QString::fromUtf8(info.peer_nickname.c_str());
QString rsid = QString::fromUtf8(info.rsid.c_str());
std::cerr << "message from rsid " << info.rsid.c_str() << std::endl;
if(!isParticipantMuted(name)) {
ui.chatWidget->addChatMsg(true, name, sendTime, recvTime, message, ChatWidget::TYPE_NORMAL);
emit messageReceived(id()) ;
}
// This is a trick to translate HTML into text.
QTextEdit editor;
editor.setHtml(message);
QString notifyMsg = name + ": " + editor.toPlainText();
if(notifyMsg.length() > 30)
MainWindow::displayLobbySystrayMsg(tr("Lobby chat") + ": " + _lobby_name, notifyMsg.left(30) + QString("..."));
else
MainWindow::displayLobbySystrayMsg(tr("Lobby chat") + ": " + _lobby_name, notifyMsg);
// also update peer list.
time_t now = time(NULL);
if (now > lastUpdateListTime) {
lastUpdateListTime = now;
updateParticipantsList();
}
}
示例10: QCOMPARE
void Test2Test::testCase4()
{
TextEdit txt;
QTextEdit mytxt;
QTest::keyClicks(&mytxt, "Pavlova Viktoria is student of BNTU");
QCOMPARE(mytxt.toPlainText(), QString("Pavlova Viktoria is student of BNTU"));
}
示例11: toString
QString QTextEditProto::toString() const
{
QTextEdit *item = qscriptvalue_cast<QTextEdit*>(thisObject());
if (item)
return QString("[ QTextEdit starting: %1... ]").arg(item->toPlainText().left(50));
return QString("QTextEdit(unknown)");
}
示例12: on_exportSavePushButton_clicked
void MainWindow::on_exportSavePushButton_clicked()
{
QListWidget* savesList = findChild<QListWidget*>("vesselsInSaveListView");
QTextEdit* savePathTextField = this->findChild<QTextEdit*>("SavePathTextEdit");
QString pathToSave = savePathTextField->toPlainText();
QFile saveFile(pathToSave);
if(!saveFile.exists() || !pathToSave.endsWith(".sfs") || !saveFile.open(QIODevice::ReadOnly))
{
QMessageBox::warning(0, "Unable to open save file for writing", "When attempting to export new save, file was not opened.");
}
QString saveText(saveFile.readAll());
std::size_t headerEnd = saveText.indexOf("VESSEL");
QString header = saveText.left(headerEnd);
saveFile.close();
saveFile.open(QIODevice::WriteOnly | QIODevice::Truncate);
m_diagnosticsWindow->append(QString("Isolated header:\n") + header + QString("\n--Writing vessels to save--\n"));
std::stringstream stringBuilder;
for(int i = 0; i < savesList->count(); i++)
{
VesselListWidgetItem* item = (VesselListWidgetItem*)savesList->item(i);
stringBuilder << item->GetVesselData()->AccessFullText()->toStdString();
}
stringBuilder << "}\n}";
saveFile.write(header.toLocal8Bit());
saveFile.write(stringBuilder.str().c_str());
saveFile.close();
}
示例13: emitChatData
/** Get a message node element, extrapolate its type (public msg, private msg, channelEnter, etc.) and emit
the specific signal */
void AJAXChat::emitChatData(const QDomElement &message)
{
QString messageText = message.firstChildElement("text").text();
// decode html entities from the message text and simplify it
QTextEdit t;
t.setHtml(messageText);
messageText = t.toPlainText().simplified();
if (messageText.startsWith("/")) {
QStringList messageParts = messageText.split(" ");
if (messageText.startsWith("/privmsg")) {
const int userID = message.attribute("userID").toInt();
emit newPrivateMessage(messageParts.at(1), getUser(userID).text());
} else if (messageText.startsWith("/login")) {
emit userLoggedIn(messageParts.at(1));
} else if (messageText.startsWith("/logout")) {
emit userLoggedOut(messageParts.at(1));
qDebug("Logged out: " + getUser(messageParts.at(1)).text().toUtf8());
} else if (messageText.startsWith("/channelEnter")) {
emit userJoinChannel(messageParts.at(1));
} else if (messageText.startsWith("/channelLeave")) {
emit userLeaveChannel(messageParts.at(1));
} else if (messageText.startsWith("/kick")) {
emit userKicked(messageParts.at(1));
} else if (messageText.startsWith("/nick")) {
emit userChangeNick(messageParts.at(1), messageParts.at(2));
}
} else {
const int userID = message.attribute("userID").toInt();
emit newPublicMessage(messageText, getUser(userID).text());
}
}
示例14: typeWriterFontChanged
void ConsoleImpl::typeWriterFontChanged() {
QTextEdit* te = textEditOutput;
te->setFont(QGit::TYPE_WRITER_FONT);
te->setPlainText(te->toPlainText());
te->moveCursor(QTextCursor::End);
}
示例15: onWatchEditChanged
void MainWindow::onWatchEditChanged()
{
watchList.clear();
QTextEdit* watchEdit = ui->watchEdit;
QStringList lines = watchEdit->toPlainText().split("\n");
bool valid = true;
QStringList validList;
QString str;
for(auto line:lines)
{
line = line.trimmed();
QFileInfo check(line);
if(check.isFile() || check.isDir())
validList.push_back(line);
else
{
valid = false;
this->statusBar()->showMessage("监视路径错误:" + line);
}
}
if(valid)
{
this->statusBar()->clearMessage();
watchList.swap(validList);
}
updateBtn();
}