本文整理汇总了C++中QTextEdit::insertPlainText方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextEdit::insertPlainText方法的具体用法?C++ QTextEdit::insertPlainText怎么用?C++ QTextEdit::insertPlainText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextEdit
的用法示例。
在下文中一共展示了QTextEdit::insertPlainText方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onMessageToGui
void Dialog::onMessageToGui(QString name, QString mes)
{
QTextEdit *output = ui->te_outputMess;
output->moveCursor(QTextCursor::End);
output->setTextColor(Qt::blue);
output->insertPlainText(QTime::currentTime().toString());
output->setTextColor(Qt::red);
output->insertPlainText("<"+name+">");
output->setTextColor(Qt::black);
output->insertPlainText(mes+"\n");
}
示例2: on_pushButton_clicked
void MainWindow::on_pushButton_clicked()
{
RFC1664 rfc;
cout << "Envoi du message au serveur !" << endl;
int i;
QString msg = ui->lineEdit->text();
string msgCom = rfc.createMsgCom(ui->label_pseudo->text().toStdString(), "", msg.toStdString(), ui->QTabWidget_onglets->tabText(ui->QTabWidget_onglets->currentIndex()).toStdString());
if(this->getLeftNeighboor() != NULL) {
cout << "J'ai un voisin a gauche et je vais lui envoyer le message [" << msgCom << "]" << endl;
NetworkUDP::sendDatagrams(this->socketClients->getSocket(), (char*)msgCom.c_str(), strlen(msgCom.c_str()), (SOCKADDR*)this->getLeftNeighboor()->getSockAddr(), this->socketClients->getAddrinfo());
}
if(this->getRightNeighboor() != NULL) {
cout << "J'ai un voisin a droite et je vais lui envoyer le message [" << msgCom << "]" << endl;
NetworkUDP::sendDatagrams(this->socketClients->getSocket(), (char*)msgCom.c_str(), strlen(msgCom.c_str()), (SOCKADDR*)this->getRightNeighboor()->getSockAddr(), this->socketClients->getAddrinfo());
}
this->ui->lineEdit->clear();
// Saisie du message envoyé dans l'IHM et dans le bon salon
msgCom = ui->label_pseudo->text().toStdString();
msgCom += " - ";
msgCom += msg.toStdString();
msgCom += "\n";
QTextEdit *text;
text = this->getRoomLists().take(ui->QTabWidget_onglets->tabText(ui->QTabWidget_onglets->currentIndex()));
text->moveCursor(QTextCursor::End);
text->insertPlainText(QString(msgCom.c_str()));
}
示例3: WriteLog
void startDialog::WriteLog(const char *logText)
{
QTextEdit *pEdit = ui->LogText;
pEdit->moveCursor(QTextCursor::End);
pEdit->insertPlainText(QString(logText));
pEdit->moveCursor(QTextCursor::End, QTextCursor::KeepAnchor);
}
示例4: replace
bool FindDialog::replace() {
bool found = find();
QTextEdit* textEdit = getCurrentTextEdit();
if (textEdit == NULL) return false;
if (found == false) return false;
textEdit->cut();
textEdit->insertPlainText(ui->replaceString->text());
return true;
}
示例5: on_lstSmileys_doubleClicked
/**
* Inserts an image tag corresponding to the clicked smiley
* into the message-textbox.
* @brief MainWindow::on_lstSmileys_doubleClicked
*/
void MainWindow::on_lstSmileys_doubleClicked(const QModelIndex &index)
{
QString img = "<img src=\"images/smileys/small/" + QString::number(index.row()) + ".png\" />";
QTextEdit* txtMsg = ui->txtMessage;
if(ui->tabgrpConversations->currentIndex() != 0)
{
txtMsg = ui->tabgrpConversations->currentWidget()->findChild<QTextEdit*>(CONVO_TAB_MSG_ID);
}
txtMsg->insertPlainText(img);
txtMsg->setFocus();
}
示例6: luatiled_qtprint
static int luatiled_qtprint (lua_State *L) {
int n = lua_gettop(L); /* number of arguments */
int i;
lua_pushstring(L, "__scriptdock__");
lua_gettable(L, LUA_REGISTRYINDEX);
QTextEdit* scriptDockOutput = reinterpret_cast<QTextEdit*>(lua_touserdata(L, -1));
lua_getglobal(L, "tostring");
for (i=1; i<=n; i++) {
const char *s;
lua_pushvalue(L, -1); /* function to be called */
lua_pushvalue(L, i); /* value to print */
lua_call(L, 1, 1);
s = lua_tostring(L, -1); /* get result */
if (s == NULL)
return luaL_error(L, LUA_QL("tostring") " must return a string to "
LUA_QL("print"));
if (i>1) scriptDockOutput->insertPlainText(QObject::tr("\t"));
scriptDockOutput->insertPlainText(QObject::tr(s));
lua_pop(L, 1); /* pop result */
}
scriptDockOutput->insertPlainText(QObject::tr("\n"));
return 0;
}
示例7: Input_letter_to_linEdit
/*********************通过键盘输入字符QLineEdit********************************/
void Keyboard::Input_letter_to_linEdit(const QString letter)
{
// if(Flag_InputMode==LETTER)
QWidget *q = QApplication::focusWidget();
QLineEdit *e;
QTextEdit *t;
if (q != NULL)
{
e = dynamic_cast<QLineEdit *>(q);//dynamic_cast用于判断q的类型是否为QLineEdit如果是,那么e就为QLineEdit。
if (e != NULL) e->insert(letter);
t = dynamic_cast<QTextEdit *>(q);
if (t != NULL) t->insertPlainText(letter);
}
}
示例8: QColor
void Ventana_Principal::on_bt_buscar_3_clicked()
{
Pestana *actual = (Pestana*)ui->tabWidget->currentWidget();
if(actual != NULL){
QTextEdit *editor = actual->textedit();
int fw1 = editor->fontWeight();
QColor gris1 = QColor("red");
editor->setFontWeight(QFont::DemiBold);
editor->setTextColor(QColor(gris1));
editor->insertPlainText("hola");
editor->setFontWeight(fw1);
editor->setTextColor(gris1);
}
//this->AnalisisJSLT();
}
示例9: glCreateShaderObjectARB
bool
ShaderFactory::loadShader(GLhandleARB &progObj,
QString shaderString)
{
GLhandleARB fragObj = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
glAttachObjectARB(progObj, fragObj);
GLhandleARB vertObj = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
glAttachObjectARB(progObj, vertObj);
{ // vertObj
QString qstr;
qstr = "varying vec3 pointpos;\n";
qstr += "void main(void)\n";
qstr += "{\n";
qstr += " // Transform vertex position into homogenous clip-space.\n";
qstr += " gl_FrontColor = gl_Color;\n";
qstr += " gl_BackColor = gl_Color;\n";
qstr += " gl_Position = ftransform();\n";
qstr += " gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;\n";
qstr += " gl_TexCoord[1] = gl_TextureMatrix[1] * gl_MultiTexCoord1;\n";
qstr += " gl_TexCoord[2] = gl_TextureMatrix[2] * gl_MultiTexCoord2;\n";
qstr += " gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;\n";
qstr += " pointpos = gl_Vertex.xyz;\n";
qstr += "}\n";
int len = qstr.length();
char *tbuffer = new char[len+1];
sprintf(tbuffer, qstr.toLatin1().data());
const char *sstr = tbuffer;
glShaderSourceARB(vertObj, 1, &sstr, NULL);
delete [] tbuffer;
GLint compiled = -1;
glCompileShaderARB(vertObj);
glGetObjectParameterivARB(vertObj,
GL_OBJECT_COMPILE_STATUS_ARB,
&compiled);
if (!compiled)
{
GLcharARB str[1000];
GLsizei len;
glGetInfoLogARB(vertObj,
(GLsizei) 1000,
&len,
str);
QMessageBox::information(0,
"Error : Vertex Shader",
str);
return false;
}
}
{ // fragObj
int len = shaderString.length();
char *tbuffer = new char[len+1];
sprintf(tbuffer, shaderString.toLatin1().data());
const char *sstr = tbuffer;
glShaderSourceARB(fragObj, 1, &sstr, NULL);
delete [] tbuffer;
GLint compiled = -1;
glCompileShaderARB(fragObj);
glGetObjectParameterivARB(fragObj,
GL_OBJECT_COMPILE_STATUS_ARB,
&compiled);
if (!compiled)
{
GLcharARB str[1000];
GLsizei len;
glGetInfoLogARB(fragObj,
(GLsizei) 1000,
&len,
str);
//-----------------------------------
// display error
//qApp->beep();
QString estr;
QStringList slist = shaderString.split("\n");
for(int i=0; i<slist.count(); i++)
estr += QString("%1 : %2\n").arg(i+1).arg(slist[i]);
QTextEdit *tedit = new QTextEdit();
tedit->insertPlainText("-------------Error----------------\n\n");
tedit->insertPlainText(str);
tedit->insertPlainText("\n-----------Shader---------------\n\n");
tedit->insertPlainText(estr);
QVBoxLayout *layout = new QVBoxLayout();
layout->addWidget(tedit);
QDialog *showError = new QDialog();
showError->setWindowTitle("Error in Fragment Shader");
showError->setSizeGripEnabled(true);
showError->setModal(true);
//.........这里部分代码省略.........
示例10: pbtnLicenseDetails_pressed
void QgsCptCityColorRampDialog::pbtnLicenseDetails_pressed()
{
QString path, title, copyFile, descFile;
// get basic information, depending on if is color ramp or directory
QgsCptCityDataItem *item = mModel->dataItem( mTreeFilter->mapToSource( mTreeView->currentIndex() ) );
if ( ! item )
return;
path = item->path();
if ( item->type() == QgsCptCityDataItem::Directory )
{
title = tr( "%1 Directory Details" ).arg( item->path() );
}
else if ( item->type() == QgsCptCityColorRampItem::Directory )
{
title = tr( "%1 Gradient Details" ).arg( path );
}
else
{
return;
}
copyFile = mArchive->copyingFileName( path );
descFile = mArchive->descFileName( path );
// prepare dialog
QgsDialog dlg( this, nullptr, QDialogButtonBox::Close );
QVBoxLayout *layout = dlg.layout();
dlg.setWindowTitle( title );
QTextEdit *textEdit = new QTextEdit( &dlg );
textEdit->setReadOnly( true );
layout->addWidget( textEdit );
// add contents of DESC.xml and COPYING.xml
QString copyText;
if ( ! copyFile.isNull() )
{
QFile file( copyFile );
if ( file.open( QIODevice::ReadOnly | QIODevice::Text ) )
{
copyText = QString( file.readAll() );
file.close();
}
}
QString descText;
if ( ! descFile.isNull() )
{
QFile file( descFile );
if ( file.open( QIODevice::ReadOnly | QIODevice::Text ) )
{
descText = QString( file.readAll() );
file.close();
}
}
textEdit->insertPlainText( title + "\n\n" );
textEdit->insertPlainText( QStringLiteral( "===================" ) );
textEdit->insertPlainText( QStringLiteral( " copying " ) );
textEdit->insertPlainText( QStringLiteral( "===================\n" ) );
textEdit->insertPlainText( copyText );
textEdit->insertPlainText( QStringLiteral( "\n" ) );
textEdit->insertPlainText( QStringLiteral( "==================" ) );
textEdit->insertPlainText( QStringLiteral( " description " ) );
textEdit->insertPlainText( QStringLiteral( "==================\n" ) );
textEdit->insertPlainText( descText );
textEdit->moveCursor( QTextCursor::Start );
dlg.resize( 600, 600 );
dlg.exec();
}