本文整理汇总了C++中QTextEdit::append方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextEdit::append方法的具体用法?C++ QTextEdit::append怎么用?C++ QTextEdit::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextEdit
的用法示例。
在下文中一共展示了QTextEdit::append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: slotNewShip
//слот - создание нового корабля
void MyServer::slotNewShip(){
deleteShipButton->setEnabled(false);
//создание корабля
ShipItemStruct* ship = new ShipItemStruct;
ship->isNew=1;
shipList.append(ship);
//если это первый корабль
if(!shipCounter){
QTextEdit *txt = (QTextEdit*) txtStack->widget(0);
txt->append("Ship created");
//shipCounter++;
timer->start(500); // TIMER
}
//если не первый корабль
else{
//создаем новый лог
QTextEdit *txt = new QTextEdit;
txt->setReadOnly(true);
txt->append("Ship created");
txtStack->addWidget(txt);
nextButton->setEnabled(true);
}
shipCounter++;
}
示例2: sendAllData
//отправление данных по всем кораблям
void MyServer::sendAllData(){
//deleteShipButton->setEnabled(false);
QByteArray block;
QDataStream out (&block, QIODevice::WriteOnly);
out.setVersion(QDataStream::Qt_5_5);
out << quint16(0) << logNumbersOfRemovedShips.size(); //количество удаленных кораблей
for(int k = 0; k < logNumbersOfRemovedShips.size(); k++){ //номер лога удаленного корабля
out << logNumbersOfRemovedShips.at(k); //
}
logNumbersOfRemovedShips.clear();
out << shipCounter; //количество существующих на сервере кораблей
//для всех кораблей
for(int i=0; i < shipCounter; i++){
generateData(shipList.at(i)); //генерируем новые данные
out << shipList.at(i)->id
<< shipList.at(i)->startX
<< shipList.at(i)->startY
<< shipList.at(i)->courseAngle
<< shipList.at(i)->speed
<< shipList.at(i)->viewAngle
<< shipList.at(i)->viewLength
<< shipList.at(i)->pathLength
<< shipList.at(i)->time;
QTextEdit *te = (QTextEdit*)txtStack->widget(i); //получение указателя на лог текущего корабля
te->append(QString("Id: %1").arg(shipList.at(i)->id+1));//вывод сгенерированной информации в лог
if(shipList.at(i)->isNew){
te->append(QString("Start X: %1\nStart Y: %2")
.arg(shipList.at(i)->startX)
.arg(shipList.at(i)->startY));
}
te->append(QString("Course angle: %1 deg\nSpeed: %2\nView angle: %3 deg\nViewLength: %4\nPath length: %5 m\nTime: %6 sec\n")
.arg(shipList.at(i)->courseAngle)
.arg(shipList.at(i)->speed).arg(shipList.at(i)->viewAngle)
.arg(shipList.at(i)->viewLength).arg(shipList.at(i)->pathLength).arg(shipList.at(i)->time/1000.0f));
shipList.at(i)->isNew=0;
}
out.device()->seek(0); //переход в начало блока
out<<quint16(block.size()-sizeof(quint16)); //размер блока данных
if(isClientConnected) socket->write(block); //посылка клиенту, если он подключен
block.clear(); //очистка используемого блока
if(!deleteShipButton->isEnabled()&& shipCounter>0) deleteShipButton->setEnabled(true);
}
示例3: file
void
CSAVE_WORKSHEET::
saveWorksheet(QTabWidget * tabWidget)
{
QTextEdit * textEdit = new QTextEdit();
QString fileName = QFileDialog::getSaveFileName(this,tr("Save PM Worksheet"), "",tr("PM Worksheet (*.pmw);;All Files (*)"));
textEdit->clear();
textEdit->hide();
if (fileName.isEmpty())
return;
else
{
QFile file(fileName);
QTextStream out(&file);
if (!file.open(QIODevice::WriteOnly))
{
QMessageBox::information(this, tr("Unable to open file"),file.errorString());
return;
}
for ( int i = 0; i < tabWidget->count(); i++ )
{
tabWidget->setCurrentIndex(i); // set to Master PM
QTableWidget *table = dynamic_cast<QTableWidget *>(tabWidget->currentWidget()); // get control
QString itemData;
textEdit->append("[ SECTION ] "+tabWidget->tabText(i));
for ( int j = 0; j < table->rowCount(); j++ )
{
for ( int k = 0; k < 12; k++ )
{
itemData.append(table->item(j,k)->text()+" | ");
}
textEdit->append(itemData.trimmed());
itemData.clear();
}
out << textEdit->toPlainText() << endl;
textEdit->clear();
}
}
tabWidget->setCurrentIndex(2);
QMessageBox::information(this, "Information", "\n Saved worksheet successfully.", QMessageBox::Ok);
}
示例4: flush
void flush(void) {
QTextBlockFormat bf = editor->textCursor().blockFormat();
bf.setBottomMargin(0);
editor->textCursor().setBlockFormat(bf);
editor->append(buffer);
buffer.clear();
}
示例5: updateOutput
void ExplorerPane::updateOutput(const QString& output)
{
QTextEdit *outputWidget = dynamic_cast<QTextEdit *>(outputPage);
if (outputWidget)
{
// Append the new output
outputWidget->append(output);
// Raise the Output tab
tabWidget->setCurrentWidget(outputPage);
}
}
示例6: overflow
virtual int overflow(int v = std::char_traits<char>::eof()) {
if (v == '\n') {
QTextBlockFormat bf = editor->textCursor().blockFormat();
bf.setBottomMargin(0);
editor->textCursor().setBlockFormat(bf);
editor->append(buffer);
buffer.clear();
} else {
buffer += (char)v;
}
return v;
}
示例7: addLinks
void NewTransferDlg::addLinks(QString links)
{
QTextEdit* target;
target = /*radioDownload->isChecked() ?*/ textURIs /*: textFiles*/;
QStringList sl = links.split('\n');
foreach (QString s, sl)
{
s = s.trimmed();
if (!target->toPlainText().contains(s))
target->append(s);
}
示例8: myPrintErrFunc
static QScriptValue myPrintErrFunc(QScriptContext *context, QScriptEngine *engine){
if (context->argumentCount() < 1)
return engine->undefinedValue();
QString result = context->argument(0).toString();
for (int i = 1; i < context->argumentCount(); i++)
result = result.arg(context->argument(i).toString());
QScriptValue calleeData = context->callee().data();
QTextEdit *textEdit = qobject_cast<QTextEdit*>(calleeData.toQObject());
if (textEdit)
textEdit->append(result);
return engine->undefinedValue();
}
示例9: QDockWindow
PanelDeHerramientas::PanelDeHerramientas(QWidget *parent, const char *name) : QDockWindow(parent, name)
{
box = new QVBox(this);
setWidget(box);
toolBox = new QToolBox (box);
QTabWidget *tab = new QTabWidget;
tab->addTab(new QWidget, "opcion1");
tab->addTab(new QWidget, "opcion2");
tab->addTab(new QWidget, "opcion2");
toolBox->addItem(tab, "Opciones");
QTextEdit *te = new QTextEdit(this);
te->append("ESTE ES EL TEXTO1");
toolBox->addItem(te, "Editor" );
QTextEdit *te2 = new QTextEdit(this);
te2->append("ESTE ES EL TEXTO2");
toolBox->addItem(te2, "Editor2" );
}
示例10: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QTabWidget *tab = new QTabWidget;
QTextEdit *edit = new QTextEdit;
Widget *w = new Widget;
tab->addTab(w, "edit");
tab->addTab(edit, "recv");
QObject::connect(w, SIGNAL(message(QString)), edit, SLOT(append(QString)));
edit->append("plain text");
tab->show();
// Widget w;
// w.show();
return a.exec();
}
示例11: main
int main (int argc, char * argv[])
{
QStringList lineList;
QString curLine;
Dictionary myDict(argv[2]);
QApplication myApp(argc, argv);
QTextEdit wid;
wid.setMinimumSize(500,300);
wid.setAcceptRichText(true);
QString word;
QTextStream stream(&word);
QFile myFile(argv[1]);
myFile.open(QIODevice::ReadOnly);
QTextStream inFile(&myFile);
while(!inFile.atEnd())
{
curLine = inFile.readLine(); //file is read
lineList = curLine.split(QRegExp("\\b"), QString::SkipEmptyParts); //the string is split into parts
for (int c = 0; c < lineList.size(); c++)
{
if (myDict.dictLook(lineList[c]) == 0) //if the word was misspelled, then
{
stream << "<font color=red>"; //red font tags are placed around the word
stream << lineList[c];
stream << "</font>";
}
else
{
stream << lineList[c]; //otherwise they are just outputted
}
}
wid.append(word); //printed to text editor
word = ""; //string cleared
}
wid.show();
return myApp.exec();
}
示例12: privateMessage
void Gui::privateMessage(const QString &receiver, const QString &message)
{
#ifdef DEBUG
qDebug() << "You got the private message";
#endif
QTextEdit* outputArea = NULL;
bool isNeededTab = false;
for (int i = 0; i < _tabs->count(); ++i)
if (_tabs->tabText(i) == receiver)
{
_outputAreas.at(i)->append(receiver + ": " + message);
isNeededTab = true;
break;
}
if (isNeededTab) return;
outputArea = new QTextEdit;
outputArea->setReadOnly(true);
_tabs->addTab(outputArea, receiver);
_outputAreas.append(outputArea);
outputArea->setGeometry(0,0,395,230);
outputArea->append(receiver + ": " + message);
}
示例13: updateErrors
void ExplorerPane::updateErrors(const QString& errors)
{
QTextEdit *errorWidget = dynamic_cast<QTextEdit *>(errorsPage);
if (errorWidget)
{
// Get the current text
QString text = errorWidget->toPlainText();
if (!text.isEmpty())
{
// Set the text color to light grey
errorWidget->setTextColor(QColor("grey"));
// Restore the current text
errorWidget->setPlainText(text);
}
// Set the text color to red
errorWidget->setTextColor(QColor("red"));
// Append the new error message
errorWidget->append(errors);
// Place cursor at end of text
errorWidget->moveCursor(QTextCursor::End);
// Raise the Error tab
tabWidget->setCurrentWidget(errorsPage);
}
}
示例14: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QTextEdit *editor = new QTextEdit;
QTextDocument *document = new QTextDocument(editor);
QTextCursor cursor(document);
QImage image(64, 64, QImage::Format_RGB32);
image.fill(qRgb(255, 160, 128));
//! [Adding a resource]
document->addResource(QTextDocument::ImageResource,
QUrl("mydata://image.png"), QVariant(image));
//! [Adding a resource]
//! [Inserting an image with a cursor]
QTextImageFormat imageFormat;
imageFormat.setName("mydata://image.png");
cursor.insertImage(imageFormat);
//! [Inserting an image with a cursor]
cursor.insertBlock();
cursor.insertText("Code less. Create more.");
editor->setDocument(document);
editor->setWindowTitle(tr("Text Document Images"));
editor->resize(320, 480);
editor->show();
//! [Inserting an image using HTML]
editor->append("<img src=\"mydata://image.png\" />");
//! [Inserting an image using HTML]
return app.exec();
}
示例15: on_actionHelp_triggered
void MainWindow::on_actionHelp_triggered()
{
// generic help
QTextEdit *pTxt = new QTextEdit(this);
pTxt->setWindowFlags(Qt::Window); //or Qt::Tool, Qt::Dialog if you like
pTxt->setReadOnly(true);
pTxt->append("qPicView by Ilkka Prusi 2011");
pTxt->append("");
pTxt->append("This program is free to use and distribute. No warranties of any kind.");
pTxt->append("Program uses Qt 4.7.1 under LGPL v. 2.1");
pTxt->append("");
pTxt->append("Keyboard shortcuts:");
pTxt->append("");
pTxt->append("* = resize/fit");
pTxt->append("+ = zoom in");
pTxt->append("- = zoom out");
pTxt->append("Left = previous");
pTxt->append("Right = next");
pTxt->append("Up/Down = scroll");
pTxt->append("");
pTxt->append("F = open file");
pTxt->append("F1 = help (this)");
pTxt->append("F11 = fullscreen toggle");
pTxt->append("Esc = close");
pTxt->append("");
pTxt->append("Tip: set as default program :)");
pTxt->show();
}